Skip to main content

VIM

Moving the cursor

(in Normal Mode)

KeyFunction
jMoves cursor down one line (same as down arrow)
kMoves cursor up line (same as up arrow)
lMoves cursor to the right one character (same as right arrow)
hMoves cursor to the left one character (same as left arrow)
wMoves cursor to beginning of next word
eMoves cursor to end of word
bMoves cursor to beginning of previous word
$Moves cursor to end of current line (same as End key)
0 (zero)Moves cursor beginning of current line (same as Home key)
3GJumps to third line (nG jumps to the nth line)
1GJumps to first line
Shift+GJumps to the last line

Editing

KeyFunction
dwDelete word
2dwDelete 2 words
uUndo last Operation
4uUndo 4 Operations
xDelete one Character
5xDelete 5 Characters
ddDelete current line
2ddDelete two lines
pPaste Buffer into line below
Shift+DDelete from the current position to the end of the line
Shift+JJoin two lines (the current and the next line)
ywCopy (yank) the current word
~Change letter to lower/uppercase
cwDelete word up to the cursor position. (especially useful in conjunction with searched matches)

Change Mode

KeyFunction
iEnter instert Mode - Cursor before current char
aInsert Mode (append) - Cursor after current char
oInsert line below and switch to insert Mode
Shift+OInsert line above and switch to insert Mode
Shift+IEnter insert Mode and jump to the beginning of the Line
Shift+AEnter insert Mode and jump to the end of the Line
KeyFunction
%s/patternSearch for a pattern
%s/pattern //gSearch and delete the pattern
nohTurn off highlighting until next search
/patternSearch. Type / without : Moves the cursor to the matched result
?patternSearch backwards.
nJump to the next result.

Save / Quit

CommandFunction/Keys
:xWill save and close the file.
:wqWill write to file and quit.
:wq!Will write to a read-only file, if possible, and quit.
ZZWill save and close. Notice that no colon : is used in this case.
:q!Exit without saving changes
:e!Discard changes and reload file
:w!Write to read-only, if possible.