Is your brain wired for Vim/VI key bindings? It takes a while to get used to modal editing, but it seems to take even longer to become accustomed to not being able to use VI keys in every program. Emacs doesn't use VI keys by default because it's Emacs. Why use Emacs when your brain is wired for VI? Packages like AUCTeX (LaTeX-editing mode) and js2-mode (awesome JavaScript mode) exist!
Want to learn how to bend Emacs to your Vim-powered will? All that junk is after the break.
Vim Emulation
Emacs comes with ViperMode for VI emulation. This is great if you were raised on VI, but Vim has more stuff that Vim users would probably miss.For Vim users, Vimpulse and Vim-Mode are two packages ('plugins' in Vim terminology) designed to provide Vim emulation in Emacs.
Vimpulse uses Viper as a basis. If you like and use Viper already, go with this! Otherwise, you might be disappointed with unexpected behavior for some of your favorite commands. For example, in Vim, typing :q would normally close the current window (among other things). In Vimpulse, doing this closes a buffer but not the corresponding window.
Vim-Mode does not use Viper as a basis. It also follows Vim's behavior more closely than Vimpulse does. I like it.
I have not tried to use both at once, but I am certain that Emacs would explode.
Unless you to use XEmacs, you'll also want redo.el. Using redo.el enables redo support in both Vim-Mode and Vimpulse.
Getting Started
The Vimpulse and Vim-Mode pages on EmacsWiki have instructions on how to install each package. Remember, if Emacs is giving you an error such as:File error: Cannot open load file, vim
You should recheck your Emacs configuration file (by default, this is ~/.emacs
) to ensure that your load-path is correct.To use redo.el, drop it in a directory (I like using ~/.emacs.d/ under Linux), then add the following to your emacs configuration file:
(require 'redo)
Configuration
Vimpulse
Vimpulse's configuration is mostly decided by Viper's configuration. Type:customize
while using Vimpulse to change Viper's settings. You can also manually edit your config file with Viper settings to configure Vimpulse.Vim-Mode
Vim-Mode's configuration is done through your config file. From there, you can add new keymaps. Here are a few examples:(vim:emap "n" 'vim:window-new) ;; allows user to press :n to open a file (vim:imap (kbd "j f") (vector vim:ESC-event)) ;; press 'jf' to exit insert-mode (vim:imap (kbd "C-x C-c") "") ;; disables dreaded Emacs exit command while in insert-mode