Design philosophies of Vim vs Emacs

From Issawiki
Revision as of 20:53, 27 November 2025 by Issa (talk | contribs) (Multiple similar commands vs single repeated command)
Jump to: navigation, search

Modal vs chording

  • Atomic edits and the dot command in Vim: When you use Vim, you naturally start to think in terms of repeatable edits that you can then use the . command to repeat. But this has a side-effect in that Vim requires you to manually chunk your undo history. Emacs instead automatically chunks undos.

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 (it does come with flyspell, which works with an external spellchecker like hunspell or aspell). (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.

See this blog post for more details.

Line-based vs character-based

Vim comes from a lineage of line-based editors. Registers can be linewise or characterwise, which means that actions like pasting text can act on entire lines or on characters. Some commands, like :substitute or :global, only work linewise.

Emacs is like most other text editors in that it has no concept of linewise.

Mappings: keystroke based vs function-based

In Vim, commands like "copy text" don't have a "name"; they are simply the keystroke that is used to perform that action. So if you want to "program" Vim to repeat some action, such as when defining a mapping, you simply tell Vim which keystrokes you want to repeat.

In Emacs, every keystroke, even entering a single character, has a function that is associated with it. Emacs is simply an interpreter that runs the function associated with the keystroke. You can always do Ctrl-h k followed by the keystroke to find which function is bound to that particular keystroke.

Actions: commands vs keybindings

Vim often uses the command-line for even common actions, e.g. :w to save a file [1]. Emacs relies more on keybindings, e.g. Ctrl-x Ctrl-s to save a file.

But there are some exceptions. To open the file that the cursor is on, Vim has various keybindings, including gf, gF, Ctrl-w f, etc., but Emacs only has M-x ffap.

Tree-based undo vs stack-based undo

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.
  • Copy-pasting: Vim gives you named registers, so if you want to copy two different lines and remember both, you do something like "ayy and "byy; then you can paste them with "ap and "bp. In Emacs, you instead kill both lines, and then when you go to paste them, you first Ctrl-y to paste the most recent, and then you do Alt-y to cycle between the most recently killed text.

In general, I feel that Vim requires more mental energy to use, in some sense. You need to pick the specific action you wanted to perform. You need to think ahead and decide which registers to use. This also comes from Vim's modal nature, but Vim gives you more decisions and a grammar, whereas Emacs gives you a way to quickly do the common thing. I think much of this may have been forced on the design of Vim by deciding to be keystroke-based, so that the only way to make some action available in normal mode was to assign some key to it. Whereas Emacs went more in the direction of being functions-first, and once you have functions, it is natural to pass arguments to the function to modify the behavior.

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.

Scrolling: scrolloff vs scroll-into-view

In Vim, defaults.vim sets scrolloff=5, which means that when the cursor is at the edge of the window, it will always show 5 lines of context. You can never "touch" the very edge of the screen, because the screen will scroll when you try to move to the edge.

In Emacs, the default behavior is instead to jerk the screen to the center after you step off the edge.

Search and replace

Emacs automatically does all the case variants, e.g. if you search and replace foo → bar, it also does Foo → Bar, FOO → Bar, etc. Vim doesn't do this.

Prompting the user

For Vim, see [2].

Emacs often prompts the user.

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.