Vim

Vim Keyboard Shortcuts

Essential Vim keyboard shortcuts - modes, navigation, editing, search, visual mode, buffers, and common commands.

Modes

ShortcutAction
iEnter Insert mode (before cursor)
aEnter Insert mode (after cursor)
IInsert at beginning of line
AInsert at end of line
oOpen new line below and enter Insert mode
OOpen new line above and enter Insert mode
vEnter Visual mode (character)
VEnter Visual mode (line)
Ctrl+VEnter Visual Block mode
REnter Replace mode
EscReturn to Normal mode
:Enter Command-line mode
ShortcutAction
h / j / k / lLeft / Down / Up / Right
wJump to start of next word
WJump to start of next WORD (whitespace-delimited)
eJump to end of word
bJump to start of previous word
0Jump to beginning of line
^Jump to first non-blank character
$Jump to end of line
ggGo to first line
GGo to last line
{number}GGo to line number
{Jump to previous paragraph
}Jump to next paragraph
Ctrl+DScroll down half page
Ctrl+UScroll up half page
Ctrl+FScroll down full page
Ctrl+BScroll up full page
HMove to top of screen
MMove to middle of screen
LMove to bottom of screen
%Jump to matching bracket
f{char}Find next char on line
F{char}Find previous char on line
t{char}Jump to before next char on line
*Search for word under cursor (forward)
#Search for word under cursor (backward)

Editing

ShortcutAction
xDelete character under cursor
XDelete character before cursor
ddDelete (cut) entire line
dwDelete word from cursor
d$ / DDelete to end of line
d0Delete to beginning of line
yyYank (copy) entire line
ywYank word
y$Yank to end of line
pPaste after cursor
PPaste before cursor
ccChange (delete and enter Insert) entire line
cwChange word
c$ / CChange to end of line
ciwChange inner word
ci"Change inside quotes
ci(Change inside parentheses
ca{Change around curly braces
r{char}Replace single character
~Toggle case
>>Indent line
<<Outdent line
.Repeat last command
uUndo
Ctrl+RRedo
JJoin line below with current

Search & Replace

ShortcutAction
/{pattern}Search forward
?{pattern}Search backward
nNext search result
NPrevious search result
:%s/old/new/gReplace all in file
:%s/old/new/gcReplace all with confirmation
:s/old/new/gReplace all on current line
:nohClear search highlighting

Visual Mode

ShortcutAction
vStart character selection
VStart line selection
Ctrl+VStart block selection
dDelete selected text
yYank selected text
>Indent selection
<Outdent selection
=Auto-indent selection
gvReselect last visual selection
oMove to other end of selection

Buffers, Windows & Tabs

ShortcutAction
:e {file}Open file in new buffer
:bn / :bpNext / previous buffer
:bdDelete (close) buffer
:spHorizontal split
:vspVertical split
Ctrl+W h/j/k/lNavigate between splits
Ctrl+W =Equal size splits
Ctrl+W _Maximize height
Ctrl+W |Maximize width
:tabnewNew tab
gt / gTNext / previous tab

Commands

ShortcutAction
:wSave file
:qQuit
:wq / ZZSave and quit
:q! / ZQQuit without saving
:waSave all buffers
:xSave and quit (only writes if changed)
:!{cmd}Execute shell command
:r {file}Read file into buffer
:set numberShow line numbers
:set pasteEnable paste mode