🟢
Comprehensive Vim cheatsheet covering modes, navigation, editing, search, buffers, macros, and text objects. Copy-paste ready.
Updated September 15, 2026
vimneovimeditorterminal
Modes
| Mode | Enter | Exit |
|---|
| Normal | Esc or Ctrl+[ | - |
| Insert | i (before) / a (after) / o (new line below) / O (new line above) | Esc |
| Visual | v (char) / V (line) / Ctrl+v (block) | Esc |
| Command | : | Esc |
| Replace | R | Esc |
Navigation
Basic Motion
| Key | Action |
|---|
h j k l | Left, down, up, right |
w / b | Next / prev word start |
e / ge | Next / prev word end |
W / B / E | Same, WORD (space-delimited) |
0 / ^ | Line start / first non-blank |
$ | Line end |
gg / G | File start / file end |
5G or :5 | Go to line 5 |
% | Jump to matching bracket |
{ / } | Prev / next empty line (paragraph) |
Ctrl+d / Ctrl+u | Half page down / up |
Ctrl+f / Ctrl+b | Full page down / up |
zz / zt / zb | Center / top / bottom current line |
Jumps
| Key | Action |
|---|
Ctrl+o | Jump back |
Ctrl+i | Jump forward |
gi | Go to last insert position |
'. | Go to last change |
Editing
Operators (combine with motion or text object)
| Key | Action |
|---|
d | Delete (cut) |
y | Yank (copy) |
c | Change (delete + enter insert) |
> / < | Indent / unindent |
= | Auto-indent |
gU / gu | Uppercase / lowercase |
Examples: dw delete word, d$ delete to end of line, yy yank line, cc change line, dd delete line.
Quick Edits
| Key | Action |
|---|
x | Delete char under cursor |
X | Delete char before cursor |
r<char> | Replace single char |
~ | Toggle case |
J | Join line below |
p / P | Paste after / before |
. | Repeat last change |
u | Undo |
Ctrl+r | Redo |
Text Objects
Use with operators: d, y, c, v, etc.
| Object | Meaning |
|---|
iw / aw | Inner word / a word (with space) |
is / as | Inner sentence / a sentence |
ip / ap | Inner 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 / at | Inside / around HTML/XML tag |
Examples: ciw change inner word, da( delete around parens, yi" yank inside quotes.
Search and Replace
| Command | Action |
|---|
/pattern | Search forward |
?pattern | Search backward |
n / N | Next / prev match |
* / # | Search word under cursor fwd / bwd |
:%s/old/new/g | Replace all in file |
:%s/old/new/gc | Replace all, confirm each |
:5,10s/old/new/g | Replace in lines 5-10 |
:s/old/new/g | Replace in current line |
Buffers, Windows, Tabs
Buffers
| Command | Action |
|---|
:ls or :buffers | List buffers |
:b<n> | Switch to buffer n |
:bn / :bp | Next / prev buffer |
:bd | Delete (close) buffer |
:e filename | Open file in buffer |
Windows (splits)
| Key / Command | Action |
|---|
Ctrl+w s or :sp | Horizontal split |
Ctrl+w v or :vsp | Vertical split |
Ctrl+w h/j/k/l | Move between windows |
Ctrl+w = | Equal size windows |
Ctrl+w q | Close window |
:close | Close current window |
Tabs
| Command | Action |
|---|
:tabnew | New tab |
gt / gT | Next / prev tab |
:tabclose | Close tab |
Marks
| Key | Action |
|---|
ma | Set mark a (local) |
mA | Set mark A (global, across files) |
`a | Jump to mark a (exact position) |
'a | Jump to mark a (line start) |
:marks | List all marks |
Macros
| Key | Action |
|---|
qa | Start recording macro into register a |
q | Stop recording |
@a | Play macro a |
@@ | Repeat last macro |
5@a | Play macro a 5 times |
File Operations
| Command | Action |
|---|
:w | Save |
:w filename | Save as filename |
:q | Quit (fail if unsaved) |
:q! | Force quit without saving |
:wq or ZZ | Save and quit |
ZQ | Force quit without saving |
:wa | Save 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