Vim
Navigation
| Action |
Shortcut |
| move cursor left |
h |
| move cursor down |
j |
| move cursor up |
k |
| move cursor down |
l |
| jump forward to the start of a word |
w |
| jump forwards to the start of a word (words can contain punctuation) |
W |
| jump forward to the end of a word |
e |
| jump forwards to the end of a word (words can contain punctuation) |
E |
| jump backwards to the start of a word |
b |
| jump backwards to the start of a word (words can contain punctuation |
B |
| jump to start of the line |
0 |
| jump to the end of line |
$ |
| go to the first line of the document |
gg |
| go to the last line of the document |
G |
| go to line 5 |
5G |
| page down |
ctrl+f |
| page up |
ctrl+b |
| search for pattern |
/pattern |
| search backward for pattern |
?pattern |
| repeat search in same direction |
n |
| repeat search in opposite direction |
N |
| jump to next x on line |
fx |
| jump before next x on line |
tx |
| jump to previous x on line |
Fx |
| jump before previous x on line |
Tx |
Editing
| Action |
Shortcut |
| undo |
u |
| redo |
ctrl+r |
| insert before cursor |
i |
| insert at the beginning of the line |
I |
| append after the cursor |
a |
| append at the end of the line |
A |
| open a new line below the current line |
o |
| open a new line above the current line |
O |
| append at the end of the word |
ea |
| append at the end of line |
$a |
| exit insert mode |
Esc |
| replace a single character |
r |
| copy a line |
yy |
| copy 2 lines |
2yy |
| copy to end of line |
y$ |
| paste the clipboard after cursor |
p |
| paste the clipboard before cursor |
P |
| delete to the end of line |
d$ |
| cut to the end of line |
D |
| delete all lines |
:%d |
| write (save) the file, but don't exit |
:w |
| write (save) and quit |
:wq or :x or ZZ |
| quit and throw away unsaved changes |
:q! or ZQ |
| write file as root but don't exit |
:w !sudo tee % |
| replace all old with new throughout file |
:%s/old/new/g |
| replace all old with new throughout file with confirmations |
:%s/old/new/gc |
Misc
| Action |
Shortcut |
| ascii to hex |
:%!xxd |
| hex to ascii |
:%!xxd -r -p |