Difference between revisions of "Design philosophies of Vim vs Emacs"
| Line 6: | Line 6: | ||
Vim tries to just be a text editor, and tries to play nice with the other tools on your computer, using commands like <code>:!command</code> (runs external command) or <code>:w !command</code> (pipes text to external command via stdin) or <code>:r !command</code> (reads from external command via stdout). | Vim tries to just be a text editor, and tries to play nice with the other tools on your computer, using commands like <code>:!command</code> (runs external command) or <code>:w !command</code> (pipes text to external command via stdin) or <code>:r !command</code> (reads from external command via stdout). | ||
| − | ==...with some exceptions== | + | ===...with some exceptions=== |
Vim has a built-in spellchecker, whereas Emacs doesn't. (Emacs comes with tetris, an RPN calculator, an email client, etc., but not a spell-checker!) | Vim has a built-in spellchecker, whereas Emacs doesn't. (Emacs comes with tetris, an RPN calculator, an email client, etc., but not a spell-checker!) | ||
Revision as of 19:49, 27 November 2025
Contents
Modal vs chording
Unix as IDE vs Emacs as OS
Vim tries to just be a text editor, and tries to play nice with the other tools on your computer, using commands like :!command (runs external command) or :w !command (pipes text to external command via stdin) or :r !command (reads from external command via stdout).
...with some exceptions
Vim has a built-in spellchecker, whereas Emacs doesn't. (Emacs comes with tetris, an RPN calculator, an email client, etc., but not a spell-checker!)
Session management: per project vs single instance
The "right way" to use Vim is to have one instance of Vim open per "project". Each Vim instance maintains its own current directory, so you can e.g. open files relative to that current directory.
In Emacs, Emacs itself doesn't maintain its current directory, and instead all file-open actions are relative to the buffer's directory.
Vim can do the Emacs thing with :set autochdir, but this is disabled by default.
Multiple similar commands vs single repeated command
This one is a bit hard to explain, but there is a definite pattern where Vim prefers to give the user multiple similar commands, while Emacs prefers to give a single command that you can then repeat or use creatively. The best way to explain is to give a bunch of examples:
- Changing the screen view relative to cursor: Vim gives you zz to scroll so as to leave the cursor at the center of the screen, zt to scroll and put the cursor at the top, and zb to scroll and put the cursor at the bottom. Emacs just gives you a single command, Ctrl-l, which when repeatedly pressed, will cycle between all three views.
- Moving cursor to top, middle, bottom: Vim gives you H to move cursor to the top of the screen, M to move to middle, and L to move to bottom. Emacs just gives you Alt-r, which will cycle between the three configurations.
- Folding: Vim gives you fine-grained commands like zo to open a fold, zc to close a fold, zR to globally reduce the fold level in the file, etc. Emacs as far as I know doesn't have folding by default, but certain major modes like org-mode and markdown-mode do have folding, and in these, you simply press TAB to cycle the different folding levels, or Shift-TAB to do the cycling globally across the entire file.
- Vim gives you Y, D, C, to copy, delete, and change (respectively) until the end of the line. Emacs just gives you Ctrl-k, which it then expects you to creatively make use of (e.g. if you want to copy until the end of the line, you do Ctrl-k to delete until the end of the line, then Ctrl-/ to undo).
- Vim has / to search forward, ? to search backward, then n or N to repeat that search in the same direction or opposite direction. Emacs just has Ctrl-s and Ctrl-r to do the search forward or backward. If you want to repeat the search, you just keep pressing Ctrl-s.
- When you have multiple split windows, Vim has Ctrl-w followed by h, j, k, or l to move to that window. It also has Ctrl-w followed by w to keep cycling between the splits. It also has Ctrl-w followed by p to toggle between the two most recent splits. There are just a lot of fine-grained choices you can make. Emacs just gives you Ctrl-x o which cycles.
- Text formatting: Vim gives you two operators, gq and gw, which format text; gq moves the cursor to the end of the formatted text, while gw tries to keep the cursor where it was before the formatting. You can then combine these operators with any motion, e.g. gwip to format the current paragraph, gww to format the current line, gwib to format inside parentheses. Emacs just gives you Alt-q to format the paragraph. It is then up to you to creatively combine that with text selection; you can select some text and then do Alt-q to format just the text that is selected.
Word movement: predictable vs "do the common thing"
Vim's word-based motions like w, b, and e always treat contiguous alphanumeric sequences as single words, and also treats contiguous symbols as single words. This leads to a pretty predictable word movement. Emacs does the thing that most other text editors do, which is that if the cursor is before a symbol, then moving forward by one word will not just jump to the end of the symbols, but will jump to the end of the alphanumeric sequence after the symbols.
Suppose you have something like: "hello" where the cursor is on the first quote. In Vim, w will move the cursor onto the h. In Emacs, Alt-f will move the cursor past the h onto the second quote.
Documentation: graph/linear vs tree
Vim uses a wiki-like help system, where you can click on links to read the sections. It also contains a linear book under :help user-manual. Emacs has a GNU-like hierarchical tree documentation system.