Vim Cheatsheet
Vim is a fast, keyboard-driven text editor. This cheatsheet covers modes, movement, editing, and search commands.
Vim is a highly efficient, keyboard-driven text editor available on virtually every Unix system. This cheatsheet covers the essential commands.
Modes
Vim is modal — commands depend on the mode.
i insert mode (before cursor)
a insert after cursor
Esc return to normal mode
v visual mode (select)
V visual line mode
: command mode
Movement
Navigate without arrow keys.
h j k l left, down, up, right
w b next / previous word
0 $ start / end of line
gg G top / bottom of file
{ } previous / next paragraph
Ctrl+d half page down
Editing
Modify text quickly.
x delete character
dd delete line
dw delete word
yy yank (copy) line
p paste after cursor
u undo
Ctrl+r redo
r<char> replace one character
cc change whole line
Search & Replace
Find and substitute.
/pattern search forward
?pattern search backward
n N next / previous match
:%s/old/new/g replace all in file
:%s/old/new/gc replace with confirm
Files
Open, save, and quit.
:w save
:q quit
:wq save and quit
:q! quit without saving
:e file open a file
Multiple Files
Work with buffers and splits.
:sp file horizontal split
:vsp file vertical split
Ctrl+w w switch windows
:bn :bp next / previous buffer
Combining Commands
Vim's power is composability.
3dd delete 3 lines
d$ delete to end of line
ci" change inside quotes
>> indent line
. repeat last command
Vim rewards muscle memory with incredible speed. Start with movement and basic editing, and run vimtutor in your terminal to practice.
For full documentation, see https://www.vim.org/docs.php