These are the most useful Vim keybindings:
| Keybinding | Action |
|---|---|
i | Enter insert mode |
Esc | Exit insert mode |
:w | Save the file |
:q | Quit Vim |
:wq | Save and quit |
dd | Delete a line |
yy | Copy (yank) a line |
p | Paste |
u | Undo |
Ctrl + r | Redo |
/text | Search for 'text' |
n | Go to the next search result |
x | Delete character under the cursor |
:set nu | Show line numbers |
:set nonu | Hide line numbers |
G | Go to the end of the file |
gg | Go to the beginning of the file |
:e filename | Open a new file |
:sp filename | Open a new file in a split window |
Ctrl + w + w | Switch between split windows |
:vs filename | Open a new file in a vertical split |
0 | Move to the beginning of the line |
$ | Move to the end of the line |
w | Move to the beginning of the next word |
b | Move to the beginning of the previous word |
c + motion | Change text that motion moves over |
v | Enter visual mode |
V | Enter visual line mode |
Ctrl + v | Enter visual block mode |
: | Enter command-line mode |
. | Repeat the last command |
:%s/old/new/g | Replace all occurrences of 'old' with 'new' |
:noh | Remove search highlighting |
:r !command | Run an external command and insert its output |