Cheatsheet for Vim and Emacs¶
Emacs and Vim are popular text editors for Linux that enable fast and efficient editing of text using special keys and keystroke combinations. Read on to find a handy cheatsheet table for common Emacs and Vim commands.
The meta key is typically the Windows key, or the command key on Mac OS.
Action | Emacs | Vim |
---|---|---|
Move forward by one character | CTRL-f | l |
Move backward by one character | CTRL-b | h |
Move forward by one word | Meta-f | w |
Move backward by one word | Meta-b | b |
Move to beginning of line | CTRL-a | 0 |
Move to end of line | CTRL-e | $ |
Transpose (swap) two characters | CTRL-t | xp |
Transpose (swap) two words | Meta-t | n/a |
Capitalize word (upper case first letter) | Meta-c | n/a |
Upper case to end of word | Meta-u | n/a |
Lower case to end of word | Meta-l | n/a |
Change case of the current character | n/a | ~ |
Insert the next character verbatim, including control characters | CTRL-v | CTRL-v |
Delete forward by one character | CTRL-d | x |
Delete backward by one character | backspace or CTRL-h | X |
Cut forward by one word | Meta-d | dw |
Cut backward by one word | Meta-backspace or CTRL-w | db |
Cut from cursor to beginning of line | CTRL-u | d^ |
Cut from cursor to end of line | CTRL-k | D |
Delete the entire line | CTRL-e CTRL-u | dd |
Paste (yank) the most recently deleted text | CTRL-y | p |
Paste (yank) the next deleted text (after previous yank) | Meta-y | n/a |
Undo the previous editing operation | CTRL-_ | u |
Undo all edits made so far | Meta-r | U |
Switch from insertion mode to command mode | n/a | Escape |
Switch from command mode to insertion mode | n/a | i |
Abort an operation in progress | CTRL-g | n/a |
Clear the display | CTRL-l | CTRL-l |
Save file and quit | CTRL-x CTRL-s | :wq |
Some people praise Vim for it's one keystroke efficiency, some prefer Emacs, which is a more full-featured editor that can do much more than text editing.