Cheatography
https://cheatography.com
Vim Cheat sheet with commands and shortcuts
This is a draft cheat sheet. It is a work in progress and is not finished yet.
File Commands
|
open a file in vim |
|
open a file explorer window |
|
save changes in the current file and quit |
|
save changes in the current file or in the new file if filename was provided |
|
save changes in the new file |
|
quit Vim |
|
quit Vim without saving changes |
Navigation
|
move left |
|
move down |
|
move up |
|
move right |
|
move to the start of the next word |
|
go to the start of a file |
|
go to the end of a file |
|
jump to the line 50 |
|
jump to the line 50 |
Edit mode
|
enter insert mode at cursor |
|
enter insert mode at the start of the line |
|
enter append mode after cursor |
|
enter append mode at the end of the line |
Deleting Text
|
delete character |
|
delete line |
|
delete to end of line |
|
delete a word (regardless of cursor position within that word) |
|
delete entire sentence (ending with a . / ? / !) |
|
delete entire paragraph |
|
delete a tag (while cursor position is on that tag) |
|
delete section between curly braces (while cursor position is within them) |
Copying and Pasting
|
yank/copy line |
|
yank/copy a word |
|
paste after cursor |
|
paste before cursor |
|
|
Find & Replace
|
start pattern serach |
|
repeat search in the same direction |
|
repeat search in the opposite direction |
|
find character forward |
|
find character backward |
|
replace all 'foo' with 'bar' in the current line |
|
replace all 'foo' with 'bar' in the whole document |
|
replace tab with spaces |
Macros
|
start recording a macro in the a
registry |
|
stop recording a macro |
|
replay a macro stored in a
registry |
|
look at the contents of a registry |
|
as a first step of the macro to start on the beginning of the line |
|
used at the end of macro to move the cursor to the next line, so that it would be easy to repeat a macro |
|
apply a macro from an a
registry for the lines in range 20 - 100 |
Windows and Files
|
split the window horizontally |
|
split the window vertically |
|
navigate between split windows (can be followed with a motion key) |
|
go to the next file |
|
go to the previous file |
|
close the current file |
Text alignment
|
center text (can be selected in visual mode) to the width of 80 |
|
left align |
|
left align text with 5 spaces indentation |
|
right align text to the width 80 |
Visual mode
|
start visual mode |
|
start linewise visual mode |
|
start visual block mode (column edit) |
|
reselect the same bit of text |
|
start linewise visual mode, select few lines and join them into a single line with J
|
|
switch case |
|
change text |
|
delete text |
|
yank |
|
replace text |
|
delete |
|
insert |
|
append |
|
join |
|
make uppercase |
|
make lowercase |
|
shift right |
|
shift left |
|