Vim Cheatsheet

Comprehensive Vim cheatsheet covering modes, navigation, editing, search, buffers, macros, and text objects. Copy-paste ready.

Updated September 15, 2026

vimneovimeditorterminal

Modes

ModeEnterExit
NormalEsc or Ctrl+[-
Inserti (before) / a (after) / o (new line below) / O (new line above)Esc
Visualv (char) / V (line) / Ctrl+v (block)Esc
Command:Esc
ReplaceREsc

Advertisement

Basic Motion

KeyAction
h j k lLeft, down, up, right
w / bNext / prev word start
e / geNext / prev word end
W / B / ESame, WORD (space-delimited)
0 / ^Line start / first non-blank
$Line end
gg / GFile start / file end
5G or :5Go to line 5
%Jump to matching bracket
{ / }Prev / next empty line (paragraph)
Ctrl+d / Ctrl+uHalf page down / up
Ctrl+f / Ctrl+bFull page down / up
zz / zt / zbCenter / top / bottom current line

Jumps

KeyAction
Ctrl+oJump back
Ctrl+iJump forward
giGo to last insert position
'.Go to last change

Editing

Operators (combine with motion or text object)

KeyAction
dDelete (cut)
yYank (copy)
cChange (delete + enter insert)
> / <Indent / unindent
=Auto-indent
gU / guUppercase / lowercase

Examples: dw delete word, d$ delete to end of line, yy yank line, cc change line, dd delete line.

Quick Edits

KeyAction
xDelete char under cursor
XDelete char before cursor
r<char>Replace single char
~Toggle case
JJoin line below
p / PPaste after / before
.Repeat last change
uUndo
Ctrl+rRedo

Text Objects

Use with operators: d, y, c, v, etc.

ObjectMeaning
iw / awInner word / a word (with space)
is / asInner sentence / a sentence
ip / apInner paragraph / a paragraph
i" / a"Inside / around double quotes
i' / a'Inside / around single quotes
i( / a(Inside / around parentheses
i{ / a{Inside / around braces
i[ / a[Inside / around brackets
it / atInside / around HTML/XML tag

Examples: ciw change inner word, da( delete around parens, yi" yank inside quotes.


Advertisement

Search and Replace

CommandAction
/patternSearch forward
?patternSearch backward
n / NNext / prev match
* / #Search word under cursor fwd / bwd
:%s/old/new/gReplace all in file
:%s/old/new/gcReplace all, confirm each
:5,10s/old/new/gReplace in lines 5-10
:s/old/new/gReplace in current line

Buffers, Windows, Tabs

Buffers

CommandAction
:ls or :buffersList buffers
:b<n>Switch to buffer n
:bn / :bpNext / prev buffer
:bdDelete (close) buffer
:e filenameOpen file in buffer

Windows (splits)

Key / CommandAction
Ctrl+w s or :spHorizontal split
Ctrl+w v or :vspVertical split
Ctrl+w h/j/k/lMove between windows
Ctrl+w =Equal size windows
Ctrl+w qClose window
:closeClose current window

Tabs

CommandAction
:tabnewNew tab
gt / gTNext / prev tab
:tabcloseClose tab

Marks

KeyAction
maSet mark a (local)
mASet mark A (global, across files)
`aJump to mark a (exact position)
'aJump to mark a (line start)
:marksList all marks

Macros

KeyAction
qaStart recording macro into register a
qStop recording
@aPlay macro a
@@Repeat last macro
5@aPlay macro a 5 times

File Operations

CommandAction
:wSave
:w filenameSave as filename
:qQuit (fail if unsaved)
:q!Force quit without saving
:wq or ZZSave and quit
ZQForce quit without saving
:waSave all buffers
:qa!Quit all without saving

Useful :set Options

set number          " line numbers
set relativenumber  " relative line numbers
set ignorecase      " case-insensitive search
set smartcase       " case-sensitive if uppercase in pattern
set hlsearch        " highlight search matches
set incsearch       " incremental search
set expandtab       " spaces instead of tabs
set tabstop=2       " tab width = 2
set shiftwidth=2    " indent width = 2
set wrap            " wrap long lines
set clipboard=unnamedplus  " use system clipboard
ToolsTagsRSSPrivacy PolicyTerms