Chair for Computer Aided Medical Procedures & Augmented Reality
Lehrstuhl für Informatikanwendungen in der Medizin & Augmented Reality

THIS WEBPAGE IS DEPRECATED - please visit our new website

Vi vs. emacs (or: "The holy war")

That's how it all started:
  • ChristianSandor - 11 May 2003: You dare to ask: vi is better than emacs! or does it have anything like the dot command (=redo) with one keystroke?
  • OtmarHilligesOld? - 05 May 2003: Yes Bub it has... (define keybindings just as you want) -- and always rember "Luke the Lisp will be with you"
  • MartinBauer - 06 May 2003: vi? emacs? Go get Hydra! -- "Woah it's the future! I must have been frozen for months!"

otmar.jpg vi-emacs2.jpg
Otmar's car: a discarded police van.

This definitely calls for a discussion! (several issues taken from this page).

  • what have vi and emacs in common (only a short list):
    • old school editors.
    • Unlimited: undo- and redo-buffer, line length, file size
    • Extendable with macros and external scripting interfaces
    • both tty and gui versions (gvim, xemacs) available
    • work on all platforms (although xemacs starts faster than vi on my Powerbook ...)
  • what is the real difference?
    • Emacs is modeless, Vi has modes (text insertion mode and command mode)
  • why is vi superior?
    • Modeless editing implies: Commands have complicated syntax and hard-to-type keystrokes, since a limited number of keys are available for commands.
    • Modeful editing implies: Many more keystrokes (~90) available for commands. Users tend to become very proficient because the fingers can stay in their normal positions almost all the time.
    • True, switching modes takes some keystrokes that are unnecessary with modeless editors. But because of the overall higher speed (see last bullet), this does not really matter. Also usually you do a cluster of commands in insert mode first, and a cluster of commands in command mode later on. So switching modes is not done very often.
    • Vi was designed to write PROGRAMS, with all other types of file possible. Emacs was designed to write TEXT, with all other types of file possible.
    • Vi is much smaller and loads much faster; it will fit on a diskette while Emacs quite definitely will not.

Still not convinced? Take a look at this. I especially love "delete paragraph"

                        VI        EMACS
              --        -----
Right one column        k         ^f
Right one word          w         Esc,f
Left one word           W         Esc,b
Next sentence           )         Esc,e
Previous sentence       (         Esc,a
Save file               :w        ^x,^s
Delete paragraph        d}        Esc,x,kill-p[TAB],[RET]
Edit a new file         e[fn]     ^x,^f,[fn]    
Exit                    :q or QQ  ^x,^c
Save and Exit           ZZ        ^x,^s,^x,k,[RET]
Repeat last search      n         ^s,[RET]
Paste from clipboard    p         ^y
Delete 7 lines          7dd       ^a,Esc,7,^k
Undo                    u         ^x,u  or ^/
Change a letter to "x"  rx        ^d,x
Go to line 6            :6[RET]   Esc,<,Esc,5,^n   

-- ChristianSandor - 10 Jun 2003

Edit | Attach | Refresh | Diffs | More | Revision r1.8 - 11 Jul 2005 - 12:53 - MarcusToennis

Lehrstuhl für Computer Aided Medical Procedures & Augmented Reality    rss.gif