Contents

Vim Cheat Sheet

Vim from the first :wq to macros, text objects, :global and a vimrc that fits, with Neovim's init.lua next to it. Every key on the page was checked against Vim 9.2's own help, and the search and replace examples show the real result of running them in Vim.

By Bogdan SanduUpdated December 2, 2026Checked against Vim 9.2

Vim command explainer

Type a Normal mode command such as d3w, ci", "+yy or gUiw, or an Ex command such as :%s/old/new/gc, and read what it does piece by piece.

Try: ct), yi{, >ip, 5x, 2gUU, @q, :g/TODO/d, :10,20s/\s\+$//e

Explanation

vimrc builder

Choose the behaviour you want and copy a vimrc for Vim, or an init.lua for Neovim. With persistent undo in Vim, create the folder once with mkdir -p ~/.vim/undo.

~/.vimrc

    

Start, Save & Quit

Vim has modes: Normal mode for moving and editing with keys, Insert mode for typing text, Visual mode for selecting and Command-line mode for commands that start with a colon. Esc always takes you back to Normal mode.

Get out, and save

How to exit Vim

If keys type text instead of running commands, press Esc first. In Vim 9.2, :Tutor starts the interactive tutorial; vimtutor in the shell works in every version.

KeysDoes
:wSave
:qQuit; refuses if there are unsaved changes
:wq or :xSave and quit; :x only writes if something changed
ZZSame as :x, from Normal mode
:q!Quit and throw away changes
ZQSame as :q!
:wa and :qaSave all, quit all
:w !sudo tee %Save a file you opened without permission to write it

Open Vim

From the shell

$ vim file.txt            # open a file
$ vim +42 file.txt        # open at line 42
$ vim +/TODO file.txt     # open at the first TODO
$ vim -O a.py b.py        # two files side by side
$ vim -d old.txt new.txt  # diff mode
$ vim -R log.txt          # read-only

Files from inside Vim

CommandDoes
:e pathEdit another file
:e!Reload the file, dropping changes
:w newnameSave a copy under another name
:saveas newnameSave under another name and keep editing it
:r fileInsert another file below the cursor
:r !dateInsert the output of a shell command

Modes

Switch modes

Enter Insert mode

KeysStarts inserting
i and aBefore and after the cursor
I and AAt the first non-blank character and at the end of the line
o and OOn a new line below and above
sDelete the character and insert
S or ccClear the line and insert
CDelete to the end of the line and insert
giWhere you last left Insert mode

Other modes

KeysMode
Esc or Ctrl+[Back to Normal mode
vVisual, characters
VVisual, whole lines
Ctrl+vVisual block, a rectangle
RReplace: typing overwrites
:Command-line mode
Ctrl+o in Insert modeRun one Normal mode command, then return

Motions

Basic movement

Characters, words and lines

A count repeats a motion: 5j moves five lines down and 3w three words forward. w stops at punctuation, W does not.

KeysMoves to
h j k lLeft, down, up, right
w and bNext word start, previous word start
e and geEnd of word, end of the previous word
W B EThe same, for words separated only by spaces
0First column of the line
^First non-blank character
$End of the line
gg and GFirst and last line
42G or :42Line 42
50%Halfway through the file

Bigger jumps

Screen and paragraph

KeysMoves to
} and {Next and previous paragraph
%The matching bracket
H M LTop, middle and bottom of the screen
Ctrl+d and Ctrl+uHalf a page down and up
Ctrl+f and Ctrl+bA page down and up
zz zt zbScroll so the cursor line is in the middle, top or bottom

Find a character on the line

KeysDoes
fx and FxJump to the next or previous x
tx and TxJump to just before the next or previous x
; and ,Repeat the last f, t, F or T forward or backward

Jumps and marks

Go back to where you were

Lowercase marks belong to one file; uppercase marks such as mA work across files.

KeysDoes
Ctrl+o and Ctrl+iBack and forward through the jump list
` . ``Position of the last change
giLast insert position, in Insert mode
maSet mark a
` a ` and 'a`Jump to mark a, or to its line
:marksList marks
gdGo to the local definition of the word under the cursor
gfOpen the file whose name is under the cursor

Operators & Text Objects

Vim edits are sentences: an operator (verb) followed by a motion or text object (noun). d + w deletes a word, c + i" changes the text inside quotes, y + ap copies a paragraph. Learn a few of each and they combine into hundreds of commands.

Operators

Verbs

Doubling an operator acts on the whole line: dd, cc, yy, >>, gUU. A count applies too: 3dd deletes three lines.

OperatorDoes
dDelete, into a register
cChange: delete, then Insert mode
yYank, which means copy
> and <Indent and unindent
=Auto-indent
gu gU g~Lowercase, uppercase, toggle case
gqFormat text to 'textwidth'
!Filter through a shell command

Text objects

Nouns that work with any operator

ObjectSelects
iw and awInner word; a word plus the space after it
is and asSentence
ip and apParagraph
i" and a"Inside quotes; including the quotes
i( or ib, a(Inside parentheses; including them
i{ or iB, a{Inside braces
i[ and i<Inside brackets and angle brackets
it and atInside an HTML or XML tag; including the tag

Combinations you will use daily

Text objects work from anywhere inside the object, so ci" works no matter where the cursor is between the quotes.

KeysDoes
ciwChange the word under the cursor
ci"Change the text inside the quotes
di(Delete the arguments of a function call
da{Delete a block including its braces
yapCopy a paragraph
citChange the content of an HTML tag
dt,Delete up to the next comma
gUiwUppercase the word
>ipIndent a paragraph
=GRe-indent to the end of the file

Basic Editing

Small edits

Characters and lines

KeysDoes
x and XDelete the character under and before the cursor
r then a characterReplace one character
~Toggle the case of the character
JJoin the next line onto this one, with a space
gJJoin without adding a space
dd and DDelete the line; delete to the end of the line
Ctrl+a and Ctrl+xAdd to or subtract from the number under the cursor
xpSwap two characters
ddpSwap two lines

Undo and repeat

The most useful key in Vim

Make an edit once, then press . at each spot that needs the same change. Combined with n, it replaces many search-and-replace jobs: /foo, cgnbar then . . ..

KeysDoes
uUndo
Ctrl+rRedo
UUndo every change on the last changed line
.Repeat the last change
g- and g+Move back and forward in time through the undo tree
:earlier 10mGo back to the file as it was ten minutes ago

Keep undo history after closing a file

Create the directory first with mkdir -p ~/.vim/undo. Neovim keeps persistent undo in its state directory without the undodir line.

~/.vimrc
set undofile
set undodir=~/.vim/undo//

Copy, Paste & Registers

Paste

Yank and put

Deleting also fills the unnamed register, so p after dd pastes the deleted line. Register 0 keeps only yanks, which fixes the classic "my copy got replaced" problem.

KeysDoes
yy or YCopy the line
yiwCopy the word
p and PPaste after and before the cursor
gpPaste and move the cursor after the pasted text
]pPaste with the indent of the current line
"0pPaste the last yank, even after deleting something

Registers

Named registers and the system clipboard

RegisterHolds
"ayy and "apYank into register a, put from it
"AyyAppend to register a
"+y and "+pThe system clipboard
"*yThe primary selection on X11, the clipboard elsewhere
"_dThe black hole register: delete without saving it
".The last inserted text
"%The current file name
":The last command line
:regShow every register
Ctrl+r a in Insert modeInsert register a

Use the system clipboard by default

This needs a Vim built with clipboard support; check vim --version | grep clipboard for +clipboard. Neovim uses a provider such as wl-copy, xclip or pbcopy, and Vim 9.2 added Wayland clipboard support.

~/.vimrc
set clipboard=unnamedplus

Visual Mode

Select, then act

Visual mode keys

KeysDoes
v, V, Ctrl+vSelect characters, lines or a block
oMove to the other end of the selection
gvSelect the previous selection again
vi" and vapSelect a text object
d, y, c, >, <, ~Act on the selection
u and ULowercase and uppercase the selection
JJoin the selected lines
:Run an Ex command on the selected lines

Edit many lines at once with a block

KeysDoes
Ctrl+v, move down, I, type, EscInsert the same text at the start of every line
Ctrl+v, move down, $A, type, EscAppend text to the end of every line
Ctrl+v, select, c, type, EscReplace a column on every line
Ctrl+v, select numbers, g Ctrl+aTurn the numbers into a sequence 1, 2, 3

Search & Replace

:substitute

Replace in the whole file

% is the range for every line and g replaces every match on a line, not just the first.

:%s/colour/color/gThe color of the color wheel.
Another color.

Whole words only, and capture groups

\< and \> mark word boundaries, so idx and valid stay. The second command works on line 2 only; with \v, very magic, groups need no backslashes and \1 and \2 put them back in a new order.

:%s/\<id\>/user_id/g
:2s/\v(\w+), (\w+)/\2 \1/user_id, idx, valid user_id
Ada Lovelace

Flags and ranges

CommandDoes
:s/a/b/First match on the current line
:%s/a/b/gcEvery match, asking for confirmation
:%s/a/b/giIgnore case
:10,20s/a/b/gLines 10 to 20
:'<,'>s/a/b/gThe visual selection, which : fills in for you
:%s/a/b/gnOnly count the matches
:%s//new/gReuse the last search pattern
:cfdo %s/a/b/g | updateEvery file in the quickfix list

Change case in the replacement

\u uppercases the next character and \L lowercases everything after it, so this turns every word into title case.

:%s/\v<(\w)(\w*)>/\u\1\L\2/gHello World From Vim

:global & Ex Commands

:global

Delete, keep or move matching lines

:g/pattern/cmd runs a command on every matching line; :v does it on every line that does not match. Here the first removes blank lines and the second keeps only warnings and errors.

:g/^\s*$/d
:v/ERROR\|WARN/dWARN slow
ERROR failed

Run Normal mode keys on many lines

:norm types keys as if you were in Normal mode on each line. Here A appends a semicolon to every line, then 0cw changes the first word of each line that starts with let.

:%norm A;
:g/^let/norm 0cwconstconst a = 1;
const b = 2;
const c = 3;

Lines as a whole

Sort, dedupe, move and copy

:sort u sorts and removes duplicate lines; :sort n sorts by number and :sort! reverses. :1m$ moves line 1 to the end; :t copies instead of moving.

:sort u
:1m$banana
pear
apple

Ex commands worth knowing

CommandDoes
:5,10dDelete lines 5 to 10
:.,+3yYank this line and the next three
:t.Duplicate the current line
:m+1 and :m-2Move the line down or up
:%!jq .Filter the whole file through a command
:.!dateReplace the line with a command's output
:retabConvert tabs to spaces using the current settings
:%s/\s\+$//eRemove trailing whitespace

Macros

Record and replay

Record a macro

Start a macro with a motion that puts the cursor in a known place, such as 0 or ^, and end it by moving to the next line, so it can run many times in a row.

KeysDoes
qaStart recording into register a
qStop recording
@aRun the macro
@@Run the last macro again
10@aRun it ten times
:'<,'>norm @aRun it on every selected line
"ap and "ay$Paste the macro to edit it, then yank it back

A macro, run from the command line

This sets register a to the keys I, dash, space, Esc, j, jumps to the first line with gg and runs the macro three times: a bulleted list in one command.

:let @a = "I- \<Esc>j"
:exe "normal gg3@a"- milk
- eggs
- bread

Windows, Buffers & Tabs

Buffers

Every open file is a buffer

CommandDoes
:lsList buffers
:b 3 or :b nameSwitch to buffer 3, or one whose name contains name
:bn and :bpNext and previous buffer
Ctrl+^The alternate buffer, the one you were in before
:bdClose the buffer
:set hiddenSwitch buffers without saving first; on by default in Neovim, off in Vim

Windows

Split the screen

KeysDoes
:sp file and Ctrl+w sSplit horizontally
:vs file and Ctrl+w vSplit vertically
Ctrl+w h j k lMove to the window left, below, above, right
Ctrl+w wNext window
Ctrl+w q and Ctrl+w cClose the window
Ctrl+w o or :onlyClose every other window
Ctrl+w =Make all windows the same size
Ctrl+w _ and Ctrl+w |Maximise the height or width
Ctrl+w + - < >Grow or shrink by one line or column
Ctrl+w H J K LMove the window to the far left, bottom, top or right

Tabs

Tab pages hold window layouts

In Vim a tab is a layout of windows, not one file. Most people work with buffers and splits and use tabs for separate tasks.

KeysDoes
:tabnew fileOpen a file in a new tab
gt and gTNext and previous tab
3gtTab 3
:tabcloseClose the tab
Ctrl+w TMove the current window into a new tab
vim -p a b cOpen files in tabs from the shell

File Explorer & Terminal

Browse and run

Built-in file explorer

CommandDoes
:ExExplore the current file's directory
:Vex and :SexExplore in a vertical or horizontal split
- in netrwUp one directory
% and d in netrwNew file, new directory
D and R in netrwDelete and rename

A terminal inside Vim

CommandDoes
:termOpen a terminal in a split
:vert termIn a vertical split
Ctrl+w NTerminal-Normal mode in Vim, to scroll and copy
Ctrl+\ Ctrl+nTerminal-Normal mode, in Vim and Neovim
:!cmdRun a shell command and show its output

Folding

Fold code

Open and close folds

KeysDoes
zaToggle the fold under the cursor
zo and zcOpen and close a fold
zR and zMOpen all folds, close all folds
zf then a motionCreate a fold, with foldmethod=manual
zj and zkMove to the next and previous fold

Pick how folds are made

foldlevelstart=99 opens files with every fold open. Other methods are syntax, marker for {{{ and }}} comments, and expr; Neovim with Tree-sitter uses foldexpr=v:lua.vim.treesitter.foldexpr().

set foldmethod=indent
set foldlevelstart=99

Insert Mode & Completion

Keys while typing

Edit without leaving Insert mode

KeysDoes
Ctrl+wDelete the word before the cursor
Ctrl+uDelete back to the start of the line
Ctrl+t and Ctrl+dIndent and unindent the line
Ctrl+r then a registerInsert a register, Ctrl+r + for the clipboard
Ctrl+o then a commandRun one Normal mode command
Ctrl+v then a keyInsert the key literally, such as a Tab

Completion

Vim 9.2 can also complete as you type: set 'autocomplete', and add fuzzy to 'completeopt' for fuzzy matching.

KeysCompletes
Ctrl+n and Ctrl+pWords from open buffers
Ctrl+x Ctrl+fFile names
Ctrl+x Ctrl+lWhole lines
Ctrl+x Ctrl+oOmni completion from the filetype or a language server
Ctrl+x Ctrl+rWords from registers (Vim 9.2)
Ctrl+x sSpelling suggestions

vimrc Essentials

A starter vimrc

Settings most people want

Vim 9.2 also reads ~/.config/vim/vimrc, following the XDG layout. Reload with :source $MYVIMRC after an edit.

~/.vimrc
set nocompatible
filetype plugin indent on
syntax on
set number relativenumber
set expandtab tabstop=4 shiftwidth=4 softtabstop=4
set autoindent
set hidden
set incsearch hlsearch ignorecase smartcase
set scrolloff=5
set mouse=a
set clipboard=unnamedplus
set undofile
let mapleader = " "
nnoremap <leader>w :w<CR>
nnoremap <leader>q :q<CR>

Mappings

Always use the noremap forms so your mapping is not expanded by other mappings. <leader> is the key you set in mapleader, often Space.

CommandMode
nnoremapNormal
inoremapInsert
vnoremap and xnoremapVisual; xnoremap leaves out Select mode
onoremapOperator-pending, for custom text objects
cnoremapCommand-line
tnoremapTerminal
:map and :verbose nmap <leader>wList mappings, and where one was set

Settings per file type

The augroup with autocmd! clears the group first, so reloading the vimrc does not add the same autocommands twice.

augroup filetypes
  autocmd!
  autocmd FileType python setlocal shiftwidth=4 textwidth=88
  autocmd FileType javascript,typescript,html,css setlocal shiftwidth=2
  autocmd BufWritePre *.py,*.js %s/\s\+$//e
augroup END

Check and change a setting

CommandDoes
:set tabstop?Show the value
:set number!Toggle a boolean setting
:setlocal spellOnly for the current buffer
:verbose set tabstop?Show where it was last set
:optionsBrowse every option

Neovim & init.lua

init.lua

The same starter config in Lua

Neovim keeps most Vim keys and Ex commands, so everything above works in it too. :checkhealth reports missing providers, clipboard tools and broken plugins.

~/.config/nvim/init.lua
vim.g.mapleader = " "
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.expandtab = true
vim.opt.shiftwidth = 4
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.clipboard = "unnamedplus"
vim.opt.undofile = true
vim.keymap.set("n", "<leader>w", "<cmd>w<cr>", { desc = "Save" })
vim.api.nvim_create_autocmd("TextYankPost", {
  callback = function() vim.hl.on_yank() end,
})

Plugins with vim.pack

Neovim 0.12

Neovim 0.12 includes vim.pack, a built-in plugin manager. lazy.nvim remains the most popular third-party one.

vim.pack.add({
  "https://github.com/neovim/nvim-lspconfig",
  "https://github.com/nvim-treesitter/nvim-treesitter",
})

Language servers

Neovim 0.11 and later

With nvim-lspconfig installed for the server definitions, vim.lsp.enable starts each server for its file types. Default keys then include K for hover, grn to rename, gra for code actions and grr for references.

vim.lsp.enable({ "lua_ls", "pyright", "ts_ls" })

Plugins in Vim

Install plugins

Native packages, no manager needed

Everything in pack/*/start loads at startup; put plugins in pack/*/opt and load them with :packadd name. Vim 9.2 ships optional packages such as comment, hlyank and nohlsearch: :packadd comment.

$ mkdir -p ~/.vim/pack/plugins/start
$ git clone https://github.com/tpope/vim-surround ~/.vim/pack/plugins/start/vim-surround

vim-plug

Run :PlugInstall after adding plugins and :PlugUpdate to update them.

~/.vimrc
call plug#begin()
Plug 'tpope/vim-surround'
Plug 'tpope/vim-fugitive'
Plug 'junegunn/fzf.vim'
call plug#end()

Plugins worth knowing

PluginFor
vim-surroundcs"' changes quotes, ysiw) wraps a word in parentheses
vim-fugitiveGit inside Vim: :Git, :Git blame, :Gdiffsplit
fzf.vimFuzzy find files, buffers and text
vim-commentarygcc comments a line; built into Vim 9.2 as the comment package and into Neovim
ALE or coc.nvimLinting and language servers in Vim

Help, Spell & Diff

Help

Read Vim's own documentation

CommandOpens
:helpThe main help page
:help ciwHelp for a key or command
:help i_CTRL-WA key in Insert mode; v_ for Visual, c_ for Command-line
:help 'tabstop'An option, in quotes
:helpgrep wordSearch all help text
Ctrl+] and Ctrl+oFollow a link, go back

Spell check

Check spelling as you type

KeysDoes
:set spell spelllang=en_usTurn on spell checking
]s and [sNext and previous misspelled word
z=Suggestions for the word
zgAdd the word to your dictionary

Diff

Compare files

KeysDoes
vim -d a b or vimdiff a bOpen in diff mode
]c and [cNext and previous change
doGet the change from the other file
dpPut this change into the other file
:diffupdateRecompute the diff

Errors & Gotchas

Common messages

What they mean

Message or symptomMeansFix
E37: No write since last changeUnsaved changes:w, or :q! to discard
E45: 'readonly' option is setOpened read-only:w!, or :w !sudo tee % for system files
E325: ATTENTION swap file foundVim crashed, or the file is open elsewherePress r to recover, then delete the .swp file
recording @q in the status lineYou pressed q by accidentPress q again to stop
The screen frozeCtrl+S paused the terminalPress Ctrl+Q
Typing runs commandsYou are in Normal modePress i to insert
Pasted code is indented more and moreAuto-indent ran on the pasteUse "+p, or :set paste before pasting in terminal Vim

Vim 9 & Neovim Versions

Release history

Recent releases

Check your version with vim --version or nvim --version. Distribution packages often lag: Ubuntu 24.04 ships Vim 9.1.

ReleaseDateHighlights
Vim 9.2February 14, 2026Autocompletion, Wayland clipboard, XDG config path, vertical tabpanel, :Tutor, Vim9 enums, generics and tuples
Vim 9.1January 2, 2024Vim9 classes and objects, smooth scrolling, virtual text
Neovim 0.12March 29, 2026Built-in vim.pack plugin manager; 0.12.7 is the current patch release
Neovim 0.112025vim.lsp.enable and vim.lsp.config, default LSP mappings

What Is a Vim Cheat Sheet

A Vim cheat sheet is a quick reference to the keys and commands of Vim, the modal text editor, grouped so you can find the key for a motion, the syntax of a substitution or the setting for your vimrc without opening the help. People also search for Vim commands, Vim shortcuts or a vi cheat sheet; they usually need it while learning the editor, editing a config file on a server or bringing Vim keys into another editor.

This one has 21 sections and 57 rows, written for Vim 9.2 and Neovim 0.12. A script looked up every key in the tables in Vim 9.2's own help, so a key that does not exist or behaves differently would have been caught. The search and replace, :global, :norm and macro examples were run in Vim on the sample text shown, and the result under them is what Vim produced.

How It Differs From vimtutor and :help

vimtutor teaches the first hour and :help documents everything, with more than a hundred files. This page sits between them: it groups the keys by what you are trying to do, shows the combinations people actually use, such as ciw, ci" and :g/^$/d, and explains the reason behind each one, so the commands stick instead of being memorised one by one.


What This Vim Cheat Sheet Covers


Vim Commands Quick Reference

TaskKeys
Save and quit:wq or ZZ
Quit without saving:q!
Insert, appendi, a, A
New line belowo
Back to Normal modeEsc
Next word, previous wordw, b
Start, end of line0, $
First, last linegg, G
Go to line 4242G or :42
Delete a linedd
Change a wordciw
Change inside quotesci"
Copy a line, pasteyy, p
Undo, redou, Ctrl+r
Repeat the last change.
Search/text, then n
Replace everywhere:%s/old/new/g
Delete blank lines:g/^$/d
Select linesV
Indent a block>ip
Record, run a macroqa ... q, @a
Split vertically:vs file
Next windowCtrl+w w
System clipboard"+y, "+p

What Vim Is

Vim is a modal text editor: keys mean different things in Normal, Insert, Visual and Command-line mode, so in Normal mode every letter is a command and you rarely need a modifier key. Bram Moolenaar released it in 1991 as Vi IMproved, an extended clone of Bill Joy's vi from 1976, and maintained it until his death in 2023; a team of long-time contributors has released Vim 9.1 and Vim 9.2 since. Neovim, started in 2014 as a fork, focuses on Lua configuration, a built-in language server client and an API for embedding. Both are free and open source; Vim is distributed from vim.org and Neovim from neovim.io.

The idea that makes Vim fast is composable editing: an operator such as d, c or y combines with any motion or text object, so learning one new motion gives you a new delete, change and copy at once. Combined with the dot command and macros, repetitive edits become a few keystrokes.

Where Vim Fits Today

Vim or a compatible vi is installed on almost every Linux server, container image and Mac, which makes it the editor you can count on over SSH, together with tmux and the Linux command line. Its keys also live inside graphical editors through plugins: VSCodeVim for VS Code, IdeaVim for JetBrains IDEs and the built-in Vim mode in Zed, so the skills carry over to whichever web development IDE your team uses.


Vim, Neovim and VS Code With Vim Keys

Vim 9.2Neovim 0.12VS Code with VSCodeVim
Config~/.vimrc, Vim script and Vim9 scriptinit.lua or init.vimsettings.json
Language serversPlugins such as coc.nvim or ALEBuilt in, with vim.lsp.enableBuilt in
Syntax parsingRegex-based syntax filesTree-sitterTextMate grammars and language servers
Plugin managerNative packages, vim-plugvim.pack, lazy.nvimMarketplace
Installed on serversUsuallyRarelyNo, remote editing instead
Keys on this pageAllAllMost Normal and Visual mode keys; Ex commands partly

Common Vim Mistakes

  • Staying in Insert mode. Vim is fastest when Normal mode is home: insert, type, Esc, move.
  • Pressing j and k twenty times. Use counts, search with / or relative line numbers and 12j.
  • Selecting with the mouse or Visual mode for everything. Text objects like ci( are faster and repeatable with dot.
  • Losing a yank after deleting. Paste from register 0 with "0p.
  • Copying a huge vimrc from the internet. Start small and add a line only when you understand why you need it.
  • Using map instead of noremap. Recursive mappings break in confusing ways when plugins add their own.

How to Learn Vim Without Losing a Week

Days One and Two

Run vimtutor, or :Tutor in Vim 9.2 and Neovim, which takes about thirty minutes. Then edit real files with only i, Esc, :w, :q, hjkl, w, b, dd, yy, p, u and /. Do not install plugins yet.

Week Two

Add one new idea per day: text objects, then the dot command, then :%s and :g, then registers and macros, then splits and buffers. When you catch yourself repeating keys, look for the motion or object that does it in one step. The regex cheat sheet helps with search patterns, keeping in mind that Vim's default regex flavour needs backslashes that the \v very magic mode removes.


How This Vim Cheat Sheet Is Maintained

Every key and command in the tables was looked up by a script in the help of Vim 9.2, and options new in 9.2, such as autocomplete and tabpanel, were checked with exists() in the same Vim. The substitute, :global, :norm and macro examples were run in Vim 9.2 in Ex mode on the sample text shown, and the result was copied under each one. Neovim facts were checked against the Neovim 0.12 documentation and release notes.

Sources: Vim 9.2 :help, including index.txt, change.txt, motion.txt, pattern.txt and version9.txt; the Neovim 0.12 documentation and news; the vim-plug, vim-surround and vim-fugitive README files.


Vim Questions People Actually Ask

How do I exit Vim?

Press Esc to make sure you are in Normal mode, then type :q and Enter to quit, :wq to save and quit, or :q! to quit and throw away your changes. ZZ saves and quits without typing a colon. If keys are being inserted as text, Esc first is the step people miss.

How do I search and replace in Vim?

Use :%s/old/new/g to replace every match in the file, where % means every line and g every match on a line. Add c to confirm each replacement and i to ignore case, and wrap the word in \< and \> to match whole words only. Select lines first and press : to limit it to the selection.

How do I copy and paste in Vim?

yy copies a line and yiw a word, and p pastes after the cursor. To use the system clipboard, prefix with "+, as in "+yy and "+p, or add set clipboard=unnamedplus to your vimrc. Deleting also fills the default register, so "0p pastes the last thing you copied.

What are text objects in Vim?

Text objects are nouns you combine with operators: iw is the inner word, i" the text inside quotes, ip a paragraph and it the inside of an HTML tag. ciw changes a word, di( deletes a function's arguments and yap copies a paragraph, from anywhere inside the object.

How do I undo and redo in Vim?

Press u in Normal mode to undo and Ctrl+r to redo. The dot command repeats the last change. Vim keeps an undo tree, so g- and g+ move through every state, :earlier 10m goes back in time, and set undofile keeps the history after you close the file.

What is the difference between Vim and Neovim?

Neovim is a fork of Vim that uses Lua for configuration and plugins, ships a built-in language server client and Tree-sitter, and has a plugin manager in version 0.12. Vim keeps Vim9 script and stays closer to classic vi. The keys, modes and Ex commands on this page work in both.

How do I record and run a macro in Vim?

Press q and a letter, such as qa, to start recording into that register, do the edit, then press q to stop. @a runs it, @@ runs it again and 10@a runs it ten times. To run it on many lines, select them and type :norm @a.

How do I show line numbers in Vim?

Type :set number for absolute line numbers or :set relativenumber for numbers relative to the cursor, which make counts like 5j easy to read. Set both to see the current line's real number with relative numbers around it, and put the line in your vimrc to keep it.

Is Vim worth learning in 2026?

Yes, if you edit text for a living. Vim is installed on nearly every server, its keys work in VS Code, JetBrains IDEs, Zed and browsers through plugins, and the operator and motion model makes repetitive edits fast. Expect a slow first week and a payoff after a month.

Can I download this Vim cheat sheet as a PDF?

Yes. Use your browser's print command and choose Save as PDF. The print layout keeps every table, example and explanation and leaves out the search box, navigation and tools. Run a search first to print only the rows that are still visible.