Cheat Sheet Library

Vim / Neovim Cheat Sheet

A modal editor. Normal mode is for moving and commands, Insert mode is for typing, Visual mode is for selecting. When in doubt, press Esc. To learn, run vimtutor (Vim) or :Tutor (Neovim).

  • 64 entries
  • 9 sections
  • Updated

64 entries

On this page

Survival #

KeyAction
iInsert before the cursor
EscBack to Normal mode
:wSave
:qQuit
:wq or ZZSave and quit
:q!Quit without saving
u / Ctrl + rUndo / redo

Entering Insert Mode #

KeyAction
i / aInsert before / after the cursor
I / AInsert at the start / end of the line
o / ONew line below / above
sDelete a character and insert
cc or SReplace the whole line

Moving #

KeyAction
h j k lLeft, down, up, right
w / b / eNext word / previous word / end of word
0 / ^ / $Line start / first character / line end
gg / GFirst / last line
42G or :42Go to line 42
%Jump to the matching bracket
{ / }Previous / next paragraph
Ctrl + d / Ctrl + uHalf page down / up
f x / t xJump to / before the next "x" on the line (; repeats)
H / M / LTop / middle / bottom of the screen

Editing #

KeyAction
xDelete a character
ddDelete (cut) the line
yyCopy (yank) the line
p / PPaste after / before
dw / cwDelete word / change word
diw / ciwDelete / change the whole word under the cursor
ci" / ci( / citChange inside quotes / brackets / HTML tag
D / CDelete / change to the end of the line
r xReplace the character with x
JJoin the next line onto this one
>> / <<Indent / unindent
.Repeat the last change
3dd, 5j…Put a number before a command to repeat it

Pattern: operator + motion, for example d (delete), c (change), y (yank) + w, $, iw, i", ap…

Visual Mode #

KeyAction
vSelect characters
VSelect lines
Ctrl + vBlock (column) select
then d / y / c / >Delete / copy / change / indent the selection
Ctrl + v, select, I, type, EscType on several lines at once

Search & Replace #

CommandAction
/text / ?textSearch forward / backward
n / NNext / previous match
* / #Search the word under the cursor
:%s/old/new/gReplace everywhere in the file
:%s/old/new/gcReplace with confirmation
:s/old/new/gReplace on the current line only
:nohClear the search highlight

Files, Buffers & Splits #

CommandAction
:e fileOpen a file
:ls / :bn / :bpList buffers / next / previous
:sp / :vspHorizontal / vertical split
Ctrl + w then h j k lMove between splits
Ctrl + w wCycle splits
:tabnew / gtNew tab / next tab
:!cmdRun a shell command

Macros & Marks #

KeyAction
qa … qRecord a macro into register a
@a / @@Play macro a / repeat the last macro
ma / 'aSet mark a / jump to mark a
Ctrl + o / Ctrl + iJump back / forward in history

Settings #

CommandAction
:set number / :set relativenumberLine numbers
:set pastePaste without auto-indent (classic Vim)
:syntax onSyntax highlighting
~/.vimrcVim config
~/.config/nvim/init.luaNeovim config (Lua)
:checkhealthNeovim: diagnose setup problems
-- minimal init.lua
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.clipboard = "unnamedplus"   -- use the system clipboard