Skip to main content

VIM Commands Cheatsheet

· 3 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

VIM Commands Cheatsheet no water, just straight to the point, such as - how to save and exit vim editor?!

Basic Navigation

CommandDescription
hMove left
jMove down
kMove up
lMove right
wJump forward to the start of the next word
bJump backward to the start of the previous word
$Go to the end of the line
0Go to the beginning of the line
ggGo to the first line of the file
GGo to the last line of the file
ctrl + fPage down
ctrl + bPage up

Editing & Inserting

CommandDescription
iInsert text before the cursor (insert mode)
aInsert text after the cursor (insert mode)
oInsert a new line below the current one
OInsert a new line above the current one
ddDelete the current line
dwDelete the current word
xDelete the character under the cursor
rReplace a single character
RReplace mode (overwrites text)
yyYank (copy) the current line
pPaste after the cursor
PPaste before the cursor

Command Mode

To enter command mode, press :.

CommandDescription
:wSave the file
:qQuit VIM
:wqSave and quit
:q!Quit without saving (force quit)
:xSave and quit (similar to :wq)
:e <filename>Open a new file
:set nuShow line numbers
:set nonuHide line numbers
:helpOpen VIM help documentation

Search and Replace

CommandDescription
/Search forward
nGo to the next search result
NGo to the previous search result
:%s/old/new/gReplace all instances of old with new in the entire file
:%s/old/new/gcReplace all instances with confirmation

Undo and Redo

CommandDescription
uUndo the last change
ctrl + rRedo the last undone change

Visual Mode

To enter visual mode, press v. This allows you to select text.

CommandDescription
vVisual mode (character-by-character selection)
VVisual line mode (select entire lines)
ctrl + vVisual block mode (select rectangular blocks)
yYank (copy) the selected text
dDelete the selected text