Vim Keyboard Shortcuts

Editor

Vim Keyboard Shortcuts

Tip: use :help <topic> to open Vim's built-in documentation.

1. Modes

ShortcutAction
iEnter insert mode before the cursor
aEnter insert mode after the cursor
oOpen a new line below
OOpen a new line above
vEnter visual mode by character
VEnter visual mode by line
<C-v>Enter visual block mode
<Esc>Return to Normal mode

2. Basic movement

ShortcutAction
hMove left
jMove down
kMove up
lMove right
wMove to the next word's start
bMove to the previous word's start
eMove to the end of the word
0Move to the beginning of the line
$Move to the end of the line
ggGo to the first line
GGo to the last line
{n}GGo to line n
%Jump to the matching bracket
zzCenter the current line

3. Editing

ShortcutAction
xDelete the character under the cursor
dwDelete a word
ddDelete the current line
DDelete to the end of the line
yyCopy the current line
ywCopy a word
pPaste after the cursor
PPaste before the cursor
uUndo
<C-r>Redo
.Repeat the last change
JJoin the current line with the next
>>Indent right
<<Indent left

4. Search and replace

ShortcutAction
/textSearch forward
?textSearch backward
nNext match
NPrevious match
:%s/old/new/gReplace all occurrences
:nohClear search highlighting

5. Files, buffers and windows

ShortcutAction
:e fileOpen a file
:wSave
:qClose the window
:q!Quit without saving
:wqSave and quit
:lsList buffers
:bnextNext buffer
:bpreviousPrevious buffer
:splitSplit horizontally
:vsplitSplit vertically
<C-w>wSwitch between windows

6. Visual mode

ShortcutAction
vSelect characters
VSelect lines
<C-v>Select a rectangular block
yCopy selection
dDelete selection
cReplace selection
>Indent selection right
<Indent selection left

7. Marks and macros

ShortcutAction
m{letter}Create a mark
'{letter}Jump to a mark
q{letter}Start recording a macro
qStop recording
@{letter}Run a macro