Vim Cheatsheet
- Author:
Adrian Karadzehenemovic
- Contact:
Modes
i – Insert mode
Esc – Normal mode
v – Visual mode
V – Visual line mode
Ctrl+v – Visual block mode
: – Command-line mode
File Operations
:w – Save
:q – Quit
:wq / :x – Save and quit
:q! – Quit without saving
:e file – Open file
:r file – Insert file contents
Movement
h j k l – Left / Down / Up / Right
w – Next word
b – Previous word
0 – Start of line
^ – First non-blank character
$ – End of line
gg – Top of file
G – Bottom of file
:n – Go to line n
Editing
i – Insert before cursor
a – Insert after cursor
o – New line below
O – New line above
x – Delete character
dd – Delete line
yy – Yank (copy) line
p – Paste after cursor
P – Paste before cursor
u – Undo
Ctrl+r – Redo
Visual Mode
v – Start visual selection
y – Yank selection
d – Delete selection
> – Indent
< – Unindent
Search and Replace
/text – Search forward
?text – Search backward
n – Next match
N – Previous match
:%s/old/new/g – Replace all
:%s/old/new/gc – Replace with confirmation
Buffers and Windows
:ls – List buffers
:b n – Switch to buffer n
:bd – Delete buffer
:split – Horizontal split
:vsplit – Vertical split
Ctrl+w w – Switch window
Ctrl+w q – Close window
Useful Extras
. – Repeat last command
ciw – Change inner word
di( – Delete inside parentheses
:%!cmd – Filter buffer through shell command
:set number – Show line numbers
:set relativenumber – Show relative line numbers