Command | Description |
---|---|
h, j, k, l | Move left, down, up, right |
w | Move to the beginning of the next word |
b | Move to the beginning of the previous word |
e | Move to the end of the current word |
0 | Move to the beginning of the line |
$ | Move to the end of the line |
gg | Move to the first line of the document |
G | Move to the last line of the document |
Command | Description |
---|---|
i | Insert mode (before cursor) |
a | Insert mode (after cursor) |
o | Insert mode (new line below) |
O | Insert mode (new line above) |
x | Delete character under cursor |
dd | Delete entire line |
yy | Yank (copy) entire line |
p | Paste after cursor |
u | Undo |
Ctrl + r | Redo |
Command | Description |
---|---|
/pattern | Search forward for pattern |
?pattern | Search backward for pattern |
n | Repeat search in same direction |
N | Repeat search in opposite direction |
:%s/old/new/g | Replace all occurrences of 'old' with 'new' in the file |
:s/old/new/g | Replace all occurrences of 'old' with 'new' in the current line |
Command | Description |
---|---|
v | Start visual mode (character-wise) |
V | Start visual mode (line-wise) |
Ctrl + v | Start visual block mode |
y | Yank (copy) selected text |
d | Delete selected text |
> | Indent selected text |
< | Outdent selected text |
Command | Description |
---|---|
:w | Save file |
:w filename | Save file as filename |
:q | Quit (fails if unsaved changes) |
:q! | Quit without saving (discard changes) |
:wq | Save and quit |
:e filename | Edit a file in a new buffer |
Command | Description |
---|---|
qa | Record macro a |
q | Stop recording macro |
@a | Run macro a |
@@ | Rerun last run macro |