This is a draft cheat sheet. It is a work in progress and is not finished yet.
Modes
Mode |
Key Press |
Description |
NORMAL |
ESC |
Can enter other modes, or use shortcuts |
COMMAND |
: |
Can execute commands |
INSERT |
i |
Insert at current position |
Cursor Navigation Shortcuts
Shortcut |
Description |
ctrl + e |
Scroll Down |
ctrl + y |
Scroll Up |
ctrl + f |
Page Down |
ctrl + b |
Page UP |
ctrl + u |
Half Page Up |
ctrl + d |
Half Page Down |
gg |
Top of File |
G |
Bottom of File |
H |
Top of Page |
M |
Middle of Page |
L |
Bottom of Page |
w |
Start of next word |
e |
End of next word |
E |
End of next word (ignore punctuation) |
b |
Start of previous word |
B |
Start of previous word (ignore punctuation) |
$ |
Move to end of current line |
0 (zero) |
Move to start of current line |
Prefixing commands with a number will repeat the command the specified number of times. For example: 5w will move the cursor to the 5th word
Command Mode Commands
Commands |
Description |
Example |
:e file |
Edit a file in a new buffer |
:e new_file.txt |
:r file |
Read in the file |
:r /tmp/file.txt |
:r !{cmd} |
Read in the CMD's STDIN |
:r !{ls -l} |
:1 (Any number) |
Go to line number |
:15 |
:/ |
Search forward for pattern |
:/string_to_find |
:? |
Search backward for pattern |
:?string_to_find |
:s |
Substitute on current line |
:s/foo/bar/ |
:%s |
Substitute in document |
:%s/foo/bar/ |
|
|
Text Entry
Shortcut |
Description |
a |
Append text following cursor |
A |
Append text to end of current line |
i |
Insert text before cursor |
I |
Insert text at start of current line |
o |
Insert text after a new line below |
O |
Insert text after a new line above |
Text Deletion
Shortcut |
Description |
x |
Delete character under cursor |
dw |
Delete word (include whitespace) |
de |
Delete to end of word (exclude whitespace) |
db |
Delete word backward (includes whitespace) |
d$ |
Delete to end of line (leaves blank line) |
dd |
Delete line |
d^ |
Delete to start of line |
Prefixing commands with a number will repeat the command the specified number of times. For example: 5dd will delete five line starting at the cursor going down.
Copy/ Pasting
Shortcut |
Description |
yy |
Yank current line |
y$ |
From cursor Yank to end of line |
yw |
From cursor tank to end of word |
p |
Paste below cursor |
P |
Past above cursor |
u |
undo last change |
U |
Restore line |
J |
Move line below to end of current line |
Prefixing commands with a number will repeat the command the specified number of times. For example: 5yy starting at the cursor will copy 5 lines going down.
Save / Close File
Command |
Description |
:w |
write to original file |
:w file |
write to new named file |
:q |
quit (no changes) |
:q! |
quit (ignore changes) |
:wq |
Save and Quit |
|