Viper is a full-featured Vi emulator for GNU Emacs and XEmacs. But if you don't use that, keep reading.
Emacs notes, from the perspective of a vi user
Problems:
* The manual calls for C-h (Ctrl-h) to be used as a special command
** but when using Putty from Windows, by default Ctrl-h just does a backspace.
** from Windows, it can't tell the difference between Ctrl-H and the backspace key
** This means if you re-map Ctrl-H, it also re-maps the Backspace key. I haven't solved this yet.
--------------------------------------------------------
To read the manual on key commands:
1) type F1, i - gets you to the info menu
2) type m, emacs, [enter] - takes you to the Emacs info file
3) Page down to "Fundamental Editing Commands", "Important Text-Changing Commands", etc. and press [enter] on the menu items you want (typing lowercase L takes you
'back' one page)
--------------------------------------------------------
Notes:
* Terminology: C-x means Ctrl-x, C-M-x means Ctrl-Meta-x - the Meta key is Alt under MS Windows)
* For some commands, holding Ctrl is required for the second character (e.g. quit: C-x, C-c), and for others commands it's not (e.g. undo: C-x u)
* Commands like this "M-x set-visited-file-name" mean: type Meta-x, then type the string 'set-visited-file-name'.
* After typing M-x you can also use tab-completion to find commands.
Translation of common Emacs commands for vi users:
command | vi | emacs |
save file | :w | C-x C-s |
save & exit read-only file | :wq! | C-x, C-c, follow prompts |
save to a different file | :w foo | M-x set-visited-file-name |
find a file to open | C-x C-f | |
delete to end of line | Shift-d | C-k |
undo | u | C-x u |
u | C-_ (hold Ctrl, press dash/hypen/underscore key) | |
redo | r | break out of undo mode, and type C-_ again |
note: these searches are case insensitive | ||
search forward | / | C-s (incremental / search-as-you-type) |
/ | C-s, [enter] (non incremental / type whole word, then search) | |
search backward | ? | C-r (incremental) |
? | C-r, [enter] (non incremental) | |
note: even these *regex* searches are case insensitive. There is a way to make them case sensitive: set the variable `case-fold-search' to `nil'. | ||
search forward using regex | C-M-s (incremental) | |
and backward | C-M-r | |
call out to the shell | ! | M-! (Meta-Shift-1) |
start a full subshell | M-x eshell |
Notes on differences to vi:
* undo commands wrap around. Once you undo all your edits, the undo command reverses direction and starts re-doing the edits! break out of the undo mode and press C-_ (undo) again to change the direction of undo/redo command.
* files are autosaved to a seperate buffer. to recover after a crash, type: M-x recover-file
Emacs-only commands:
list commands in help menu | F1, ? |
get help on key combinations | F1, k, [some key combination] |
toggle read-only status of the buffer | C-x, C-q |
get out of a command | C-g |
redo an edit (undo the undo) | type any harmless character to break out of undo mode. You will now be able to undo your undo commands. |
remove help window | C-x 1 |
scroll the help | C-M-v |
re-map a key | M-x global-set-key [enter] |