When I was in college, I participated in vi vs. emacs editor wars. I don't recall how serious they were. My good reasons were that I was pulled into vi first, and emacs was slower to start up. At some point I'd definitely matured to finding them less interesting, and granting that emacs was probably at least as powerful as vi, or even the later vim, but I had little reason to switch.
Recently a Windows-using friend was snarking at vim as well as at git, and a bunch of good-natured ribbing ensued, but I wandered off into serious musings:
* To be honest, I'm not in a good position to say vim is 'better' than other editors, because I don't know other editors well!
* That said, vim has a lot of word-processor-like and other features which I'm fairly sure casual text editors don't. To whit:
o Macros: the ability to define or even record sequences of commands or text. I've had macros that invoked other macros.
o History: not just an unbounded undo history of text changes, but a memory for the last command and the ability to trivially repeat it, as well as a history of :commands such as replaces. I think vim also has a notion of history as a *tree*, though I've never grokked that. But the "do the last edit I did"? I use that one all the time.
o Formatting: separate commands for reformatting ordinary text and code.
o Movement: sophisticated movement commands, useful not just for moving your cursor, but for applying edit commands to (so, "delete 3 sentences", or "replace 5 paragraphs"), or (in vim) for selecting text. You could use a mouse for similar selections, but often the keyboard commands would be faster and take less arm movement.
o Marks: you can make bookmarks within files to easily jump between points, and these marks can persist across multiple files.
o IDE-like features: syntax highlighting, smart indentation, bouncing between brackets, more. A dedicated IDE is probably even better -- but if you use multiple languages, having one decent interface across them can beat having to use multiple interfaces, especially if the IDE is less sophisticated as an editor.
* Registers: if you want, you can suck text into up to 27 different clipboards.
o Completion that defaults to using the current file as a dictionary, but that can take arbitrary other dictionaries.
o And for those who can't stand funky movement keys in command mode, vim has long recognized arrow keys in editing mode, and there's a graphical vim that probably recognizes mice.
Some practical cases:
* Having to edit an IP address in lots of files:
vi *.json #edit multiple files
/192 #search for old IP
cW{new IP} #change word to new one
n. #search for next instance, and repeat last action
n. #ditto
:wn #write this file, go to the next file
n. #continue the search and replace
n.
:wn
n. #...etc, for like a dozen files
* I've had to edit the etc/hosts file on my Windows machine between two different states. Notepad++ makes a single search and replace fairly easy, and remembers the last one done, but not the last two, and the time between changes was long enough that I wasn't keeping it open to exploit undo/redo. vim could easily remember two different replace commands to invoke.
(An alternative would have been to keep two different files around, but Windows GUI doesn't make copy-and-rename that easy either, compared to a command line.)
So how does all this compare to a good Windows text editor like Notepad++? Looking at it, it does have lots of features I haven't used. There's a Macro menu, via Recording, so that's promising -- though I wonder what its notion of commands can be. The Search menu has a couple of bracket options (find matching, select to matching), though using the % key in vi would definitely be faster; also has Bookmark. Some options I doubt vim has, like 'sort lines'. (Checks: I was wrong, vim does have it.)
Overall it's a decent set of features, and for the casual or new user, the menus will be more discoverable than reading through vim documentation. But I doubt, not just from gut feeling but from comparing myself to my boss and his IDE use, that it could ever be as fast as vim mastery. Between vim and 'screen' (for switching between windows, and for cut and paste), my hands typically never have to leave the alphanumeric keyboard, not even as far as the laptop touchpad or function keys, during coding. And personally, the lack of command history would be very nearly crippling.
I was going to give Notepad++ an advantage on spellchecking, but I looked, and hey, vim has an option for that too:
:setlocal spell spelllang=en_us
And though I've never used it, there is a GUI version of vim, with at least some menus. I just found a screenshot where its Edit menu has Undo, Redo, and Repeat, and a university guide says
"Next to every menu item is a keyboard shortcut to execute that function. gVim allows a new user to easily find common functions through the menu bar, but also gives the user the keystrokes that access the function faster, and are compatible with vim and usually vi." So even the discoverability advantage of Notepad++ fades away: between it and gvim, we have two fairly powerful editors, except that the latter allows everything to be done with the keyboard and has a potent command history.
Huh. When I started this post, I was going to avoid "my editor is better", and stick to "my editor does these cool things." And then I was checking Notepad++ features and being impressed by what it had (I hadn't known it had macros). But now I seem to have argued myself into "vim, or at least gvim, quite plausibly *is* better: it can do everything[1] yours can, *and* these things unique to it (and maybe emacs.)"
[1] Not everything a great IDE can do, but I'm fine with that; I don't need my editor to compile code for me, there's a command line for that.
Edit: All that said, I just installed gvim, and its menus do seem less complete than Notepad++'s. In particular, while Repeat is there, I don't see any menu options for creating macros, plus many of the other things N++ makes available, like "sort lines". (On the IDE front, it *does* have "make" and stuff like "find next error".) I know that you can create new menus for gvim, and maybe someone has created more comprehensive ones, but a newbie won't know that. And while there's online help, it's vimmy in navigation. So I have to give newbie friendliness back to Notepad++.
Edit 2: After some further thought and reading, I'll posit that for fast and flexible general text editing, nothing beats vim mastery, not even emacs. For general programmability beyond being an editor, nothing beats emacs. For integration with some specific language, hopefully an IDE gives features that even IDE-like features of vim don't... but it probably is inferior as a text editor, which makes it a matter of tradeoffs: what do you want to optimize for? And how much do you want to be tied to a language-specific tool?
Recently a Windows-using friend was snarking at vim as well as at git, and a bunch of good-natured ribbing ensued, but I wandered off into serious musings:
* To be honest, I'm not in a good position to say vim is 'better' than other editors, because I don't know other editors well!
* That said, vim has a lot of word-processor-like and other features which I'm fairly sure casual text editors don't. To whit:
o Macros: the ability to define or even record sequences of commands or text. I've had macros that invoked other macros.
o History: not just an unbounded undo history of text changes, but a memory for the last command and the ability to trivially repeat it, as well as a history of :commands such as replaces. I think vim also has a notion of history as a *tree*, though I've never grokked that. But the "do the last edit I did"? I use that one all the time.
o Formatting: separate commands for reformatting ordinary text and code.
o Movement: sophisticated movement commands, useful not just for moving your cursor, but for applying edit commands to (so, "delete 3 sentences", or "replace 5 paragraphs"), or (in vim) for selecting text. You could use a mouse for similar selections, but often the keyboard commands would be faster and take less arm movement.
o Marks: you can make bookmarks within files to easily jump between points, and these marks can persist across multiple files.
o IDE-like features: syntax highlighting, smart indentation, bouncing between brackets, more. A dedicated IDE is probably even better -- but if you use multiple languages, having one decent interface across them can beat having to use multiple interfaces, especially if the IDE is less sophisticated as an editor.
* Registers: if you want, you can suck text into up to 27 different clipboards.
o Completion that defaults to using the current file as a dictionary, but that can take arbitrary other dictionaries.
o And for those who can't stand funky movement keys in command mode, vim has long recognized arrow keys in editing mode, and there's a graphical vim that probably recognizes mice.
Some practical cases:
* Having to edit an IP address in lots of files:
vi *.json #edit multiple files
/192 #search for old IP
cW{new IP} #change word to new one
n. #search for next instance, and repeat last action
n. #ditto
:wn #write this file, go to the next file
n. #continue the search and replace
n.
:wn
n. #...etc, for like a dozen files
* I've had to edit the etc/hosts file on my Windows machine between two different states. Notepad++ makes a single search and replace fairly easy, and remembers the last one done, but not the last two, and the time between changes was long enough that I wasn't keeping it open to exploit undo/redo. vim could easily remember two different replace commands to invoke.
(An alternative would have been to keep two different files around, but Windows GUI doesn't make copy-and-rename that easy either, compared to a command line.)
So how does all this compare to a good Windows text editor like Notepad++? Looking at it, it does have lots of features I haven't used. There's a Macro menu, via Recording, so that's promising -- though I wonder what its notion of commands can be. The Search menu has a couple of bracket options (find matching, select to matching), though using the % key in vi would definitely be faster; also has Bookmark. Some options I doubt vim has, like 'sort lines'. (Checks: I was wrong, vim does have it.)
Overall it's a decent set of features, and for the casual or new user, the menus will be more discoverable than reading through vim documentation. But I doubt, not just from gut feeling but from comparing myself to my boss and his IDE use, that it could ever be as fast as vim mastery. Between vim and 'screen' (for switching between windows, and for cut and paste), my hands typically never have to leave the alphanumeric keyboard, not even as far as the laptop touchpad or function keys, during coding. And personally, the lack of command history would be very nearly crippling.
I was going to give Notepad++ an advantage on spellchecking, but I looked, and hey, vim has an option for that too:
:setlocal spell spelllang=en_us
And though I've never used it, there is a GUI version of vim, with at least some menus. I just found a screenshot where its Edit menu has Undo, Redo, and Repeat, and a university guide says
"Next to every menu item is a keyboard shortcut to execute that function. gVim allows a new user to easily find common functions through the menu bar, but also gives the user the keystrokes that access the function faster, and are compatible with vim and usually vi." So even the discoverability advantage of Notepad++ fades away: between it and gvim, we have two fairly powerful editors, except that the latter allows everything to be done with the keyboard and has a potent command history.
Huh. When I started this post, I was going to avoid "my editor is better", and stick to "my editor does these cool things." And then I was checking Notepad++ features and being impressed by what it had (I hadn't known it had macros). But now I seem to have argued myself into "vim, or at least gvim, quite plausibly *is* better: it can do everything[1] yours can, *and* these things unique to it (and maybe emacs.)"
[1] Not everything a great IDE can do, but I'm fine with that; I don't need my editor to compile code for me, there's a command line for that.
Edit: All that said, I just installed gvim, and its menus do seem less complete than Notepad++'s. In particular, while Repeat is there, I don't see any menu options for creating macros, plus many of the other things N++ makes available, like "sort lines". (On the IDE front, it *does* have "make" and stuff like "find next error".) I know that you can create new menus for gvim, and maybe someone has created more comprehensive ones, but a newbie won't know that. And while there's online help, it's vimmy in navigation. So I have to give newbie friendliness back to Notepad++.
Edit 2: After some further thought and reading, I'll posit that for fast and flexible general text editing, nothing beats vim mastery, not even emacs. For general programmability beyond being an editor, nothing beats emacs. For integration with some specific language, hopefully an IDE gives features that even IDE-like features of vim don't... but it probably is inferior as a text editor, which makes it a matter of tradeoffs: what do you want to optimize for? And how much do you want to be tied to a language-specific tool?
no subject
Date: 2018-04-25 17:04 (UTC)From:no subject
Date: 2018-04-26 01:38 (UTC)From:Its advantages for me are:
(1) Being able to keep my hands on the keyboard. I use the trackball for some Web interactions, but by & large I am too twitchy to be comfortable using it for detail work.
(2) The extension language, Elisp, which I have learned enough about to write many routines, both general-purpose and dedicated to particular jobs, customers, etc.
(3) I like the FSF's attitude, tho I fear their cause is lost.