normal·mode

cheat sheet

Every key taught in the drills, generated from the lessons. Click a key's lesson to practise it.

415 keys

1Moving Around

hleft one characterh j k l, and counts
jdown one lineh j k l, and counts
kup one lineh j k l, and counts
lright one characterh j k l, and counts
{count}jdown {count} lines, e.g. 4j (read the count from the gutter)h j k l, and counts
{count}kup {count} linesh j k l, and counts
{count}{motion}repeat any motion {count} times, e.g. 3lh j k l, and counts
wstart of the next wordWords and WORDS: w b e ge, W B E gE
bback to the start of a wordWords and WORDS: w b e ge, W B E gE
eend of the wordWords and WORDS: w b e ge, W B E gE
geback to the end of the previous wordWords and WORDS: w b e ge, W B E gE
Wstart of the next WORD (whitespace-separated)Words and WORDS: w b e ge, W B E gE
Bback to the start of a WORDWords and WORDS: w b e ge, W B E gE
Eend of the WORDWords and WORDS: w b e ge, W B E gE
gEback to the end of the previous WORDWords and WORDS: w b e ge, W B E gE
0first column of the lineAlong a line: 0 ^ $ g_ and |
^first non-blank character of the lineAlong a line: 0 ^ $ g_ and |
$last character of the lineAlong a line: 0 ^ $ g_ and |
g_last non-blank character of the lineAlong a line: 0 ^ $ g_ and |
{count}|column {count} of the line, e.g. 51|Along a line: 0 ^ $ g_ and |
ggfirst line of the fileThe whole file: gg, G, {n}G and :{n}
Glast line of the fileThe whole file: gg, G, {n}G and :{n}
{count}Gline {count}, e.g. 12G (12gg works too)The whole file: gg, G, {n}G and :{n}
:{count}<CR>line {count} from the command line (not a jump)The whole file: gg, G, {n}G and :{n}
}forward to the next blank line (paragraph)Blocks and sentences: { } ( )
{back to the previous blank lineBlocks and sentences: { } ( )
)start of the next sentenceBlocks and sentences: { } ( )
(back to the start of a sentenceBlocks and sentences: { } ( )
Htop line of the window ({count}H: count from the top)The screen: H M L, scrolling and zz
Mmiddle line of the windowThe screen: H M L, scrolling and zz
Lbottom line of the window ({count}L: count from the bottom)The screen: H M L, scrolling and zz
<C-d>scroll half a screen downThe screen: H M L, scrolling and zz
<C-u>scroll half a screen upThe screen: H M L, scrolling and zz
<C-f>scroll a screen forward (down)The screen: H M L, scrolling and zz
<C-b>scroll a screen back (up)The screen: H M L, scrolling and zz
<C-e>scroll the view down one lineThe screen: H M L, scrolling and zz
<C-y>scroll the view up one lineThe screen: H M L, scrolling and zz
zzscroll so the cursor line is in the middleThe screen: H M L, scrolling and zz
ztscroll so the cursor line is at the topThe screen: H M L, scrolling and zz
zbscroll so the cursor line is at the bottomThe screen: H M L, scrolling and zz
z.like zz, and also moves to the first non-blankThe screen: H M L, scrolling and zz

2Insert Mode

iinsert before the cursorDoors into Insert mode: i, a, I, A, o, O
aappend after the cursorDoors into Insert mode: i, a, I, A, o, O
Iinsert before the first non-blank of the lineDoors into Insert mode: i, a, I, A, o, O
Aappend at the end of the lineDoors into Insert mode: i, a, I, A, o, O
oopen a new line below and insertDoors into Insert mode: i, a, I, A, o, O
Oopen a new line above and insertDoors into Insert mode: i, a, I, A, o, O
giinsert where Insert mode was last stoppedDoors into Insert mode: i, a, I, A, o, O
<Esc>leave Insert modeDoors into Insert mode: i, a, I, A, o, O
<C-h>delete the character before the cursor (like <BS>)Fix it without leaving: <C-h>, <C-w>, <C-u>
<C-w>delete the word before the cursorFix it without leaving: <C-h>, <C-w>, <C-u>
<C-u>delete everything before the cursor on the line (keeps the indent)Fix it without leaving: <C-h>, <C-w>, <C-u>
r{char}replace the character under the cursorType over text: r and R
{count}r{char}replace count characters with {char}Type over text: r and R
r<CR>replace the character with a line breakType over text: r and R
RReplace mode: type over existing textType over text: r and R
<BS>in Replace mode: restore the character you typed overType over text: r and R
<C-o>{cmd}run one Normal-mode command, then return to Insert modeBorrow one Normal command: <C-o>
<C-r>0insert the last yankPaste while typing: <C-r>{register}
<C-r>"insert the unnamed register (last yank or delete)Paste while typing: <C-r>{register}
<C-r>{a-z}insert a named registerPaste while typing: <C-r>{register}
<C-r>-insert the last small deletePaste while typing: <C-r>{register}
<C-k>{a}{b}insert the digraph {a}{b}, e.g. e' → éCharacters your keyboard lacks: <C-k> and <C-v>
<C-v>u{hex}insert a Unicode character by its 4-digit hex codeCharacters your keyboard lacks: <C-k> and <C-v>
<C-v>{key}insert the next key literally, e.g. a real tabCharacters your keyboard lacks: <C-k> and <C-v>
<C-v>{decimal}insert a character by its decimal value (up to 255)Characters your keyboard lacks: <C-k> and <C-v>
<C-r>=evaluate an expression and insert the resultDo the maths in place: <C-r>=
<C-r>{reg}on the = prompt: paste a register into the expressionDo the maths in place: <C-r>=
<CR>on the = prompt: evaluate and insert (<Esc> cancels)Do the maths in place: <C-r>=

3Operators & the Dot

d{motion}delete over a motionOperator + motion: d, c and y
c{motion}change: delete over a motion, then Insert modeOperator + motion: d, c and y
y{motion}yank (copy) over a motionOperator + motion: d, c and y
dwdelete to the start of the next wordOperator + motion: d, c and y
dedelete to the end of the wordOperator + motion: d, c and y
dbdelete back to the start of the wordOperator + motion: d, c and y
d$delete to the end of the lineOperator + motion: d, c and y
d0delete back to the start of the lineOperator + motion: d, c and y
cwchange to the end of the word (like ce)Operator + motion: d, c and y
dddelete the lineLine shortcuts: dd, cc, D, C, J and friends
ccchange the line (keeps the indent)Line shortcuts: dd, cc, D, C, J and friends
yyyank the lineLine shortcuts: dd, cc, D, C, J and friends
Ddelete to the end of the line (d$)Line shortcuts: dd, cc, D, C, J and friends
Cchange to the end of the line (c$)Line shortcuts: dd, cc, D, C, J and friends
Yyank to the end of the line (y$)nvimLine shortcuts: dd, cc, D, C, J and friends
xdelete the character under the cursorLine shortcuts: dd, cc, D, C, J and friends
Xdelete the character before the cursorLine shortcuts: dd, cc, D, C, J and friends
ssubstitute the character (cl)Line shortcuts: dd, cc, D, C, J and friends
Ssubstitute the whole line (cc)Line shortcuts: dd, cc, D, C, J and friends
Jjoin the next line onto this oneLine shortcuts: dd, cc, D, C, J and friends
gJjoin without adding or removing spacesLine shortcuts: dd, cc, D, C, J and friends
pput after the cursor (whole lines: below)Put, undo and redo: p, P, u and <C-r>
Pput before the cursor (whole lines: above)Put, undo and redo: p, P, u and <C-r>
uundo the last changePut, undo and redo: p, P, u and <C-r>
<C-r>redoPut, undo and redo: p, P, u and <C-r>
xpswap two charactersPut, undo and redo: p, P, u and <C-r>
ddpswap a line with the next onePut, undo and redo: p, P, u and <C-r>
yypduplicate a linePut, undo and redo: p, P, u and <C-r>
.repeat the last changeThe dot command: repeat the last change
{count}.repeat it with a new countThe dot command: repeat the last change
f{char}jump to the next {char} on the lineThe dot command: repeat the last change
;repeat the last f, t, F or TThe dot command: repeat the last change
Aappend at the end of the lineThe dot command: repeat the last change
*search forward for the word under the cursorRename one at a time: *, n and cgn
#search backward for the word under the cursorRename one at a time: *, n and cgn
nnext matchRename one at a time: *, n and cgn
Nprevious matchRename one at a time: *, n and cgn
cgnchange the next match (repeat with .)Rename one at a time: *, n and cgn
dgndelete the next matchRename one at a time: *, n and cgn
{Visual}*search for the selected textnvimRename one at a time: *, n and cgn
{count}{cmd}do a command count timesCounts: do it N times
3dwdelete three wordsCounts: do it N times
d3wthe same: the count can follow the operatorCounts: do it N times
3pput three timesCounts: do it N times
<C-a>add [count] to the number at or after the cursorCounts: do it N times
<C-x>subtract [count] from the number at or after the cursorCounts: do it N times
gU{motion}make uppercaseCase, indent and replace: gU, gu, >, < and r
gu{motion}make lowercaseCase, indent and replace: gU, gu, >, < and r
g~{motion}swap caseCase, indent and replace: gU, gu, >, < and r
gUUuppercase the line (guu, g~~ likewise)Case, indent and replace: gU, gu, >, < and r
>{motion}shift lines rightCase, indent and replace: gU, gu, >, < and r
<{motion}shift lines leftCase, indent and replace: gU, gu, >, < and r
>>shift the line right (<< shifts left)Case, indent and replace: gU, gu, >, < and r
={motion}re-indent lines (== for one line)Case, indent and replace: gU, gu, >, < and r
~toggle the case of one character and move rightCase, indent and replace: gU, gu, >, < and r
r{char}replace the character under the cursorCase, indent and replace: gU, gu, >, < and r

4Find & Jump

f{char}forward onto the next {char} on the lineFind a character: f, t, F, T, ; and ,
t{char}forward till just before the next {char}Find a character: f, t, F, T, ; and ,
F{char}backward onto the previous {char}Find a character: f, t, F, T, ; and ,
T{char}backward till just after the previous {char}Find a character: f, t, F, T, ; and ,
;repeat the last f/t/F/TFind a character: f, t, F, T, ; and ,
,repeat the last f/t/F/T in the opposite directionFind a character: f, t, F, T, ; and ,
%jump to the matching bracket (finds the next bracket on the line first)Matching pairs: %, [( and [{
[(back to the unclosed ( around the cursorMatching pairs: %, [( and [{
[{back to the unclosed { around the cursorMatching pairs: %, [( and [{
])forward to the ) that closes the current groupMatching pairs: %, [( and [{
]}forward to the } that closes the current blockMatching pairs: %, [( and [{
m{a-z}set a mark at the cursorMarks: m, ` and '
`{a-z}jump to the exact position of a markMarks: m, ` and '
'{a-z}jump to the first non-blank of the mark's lineMarks: m, ` and '
``back to the position before the latest jumpMarks: m, ` and '
''back to the line of the position before the latest jumpMarks: m, ` and '
m{A-Z}set a file mark (remembers the file too)Marks: m, ` and '
:markslist the marksMarks: m, ` and '
<C-o>back to an older position in the jump listThe jump list: CTRL-O and CTRL-I
<C-i>forward to a newer position in the jump listThe jump list: CTRL-O and CTRL-I
<Tab>same as CTRL-IThe jump list: CTRL-O and CTRL-I
:jumpsshow the jump list (:ju for short)The jump list: CTRL-O and CTRL-I
g;go to an older position in the change listThe change list: g; and g,
g,go to a newer position in the change listThe change list: g; and g,
`.exact position of the last changeThe change list: g; and g,
'.line of the last changeThe change list: g; and g,
`^where Insert mode was last stoppedThe change list: g; and g,
:changesshow the change listThe change list: g; and g,

5Text Objects

iwinner word: the word under the cursorWords: iw, aw, iW and aW
awa word: the word plus the space after it (or before)Words: iw, aw, iW and aW
iWinner WORD: everything up to the surrounding spacesWords: iw, aw, iW and aW
aWa WORD plus its spaceWords: iw, aw, iW and aW
ciwchange the word under the cursorWords: iw, aw, iW and aW
dawdelete a word and one spaceWords: iw, aw, iW and aW
i"inside double quotesQuotes: i", a", i' and i`
a"a double-quoted string, quotes and trailing space includedQuotes: i", a", i' and i`
i'inside single quotesQuotes: i", a", i' and i`
a'a single-quoted stringQuotes: i", a", i' and i`
i`inside backticksQuotes: i", a", i' and i`
a`a backtick stringQuotes: i", a", i' and i`
ci"change a string's contentsQuotes: i", a", i' and i`
i(inside parentheses (also i) and ib)Brackets: i(, i{, i[ and i<
a(parentheses and their contents (also a) and ab)Brackets: i(, i{, i[ and i<
i{inside braces (also i} and iB)Brackets: i(, i{, i[ and i<
a{braces and their contents (also a} and aB)Brackets: i(, i{, i[ and i<
i[inside square bracketsBrackets: i(, i{, i[ and i<
a[square brackets and their contentsBrackets: i(, i{, i[ and i<
i<inside angle bracketsBrackets: i(, i{, i[ and i<
a<angle brackets and their contentsBrackets: i(, i{, i[ and i<
2i(inside the next pair of parentheses outBrackets: i(, i{, i[ and i<
itinner tag: the element's contentsTags: it and at
ata tag: the whole element with its tagsTags: it and at
citchange the element's contentsTags: it and at
datdelete the whole elementTags: it and at
2itthe contents of the element one level outTags: it and at
isinner sentenceSentences and paragraphs: is, as, ip and ap
asa sentence plus the space after itSentences and paragraphs: is, as, ip and ap
ipinner paragraph: the lines up to a blank lineSentences and paragraphs: is, as, ip and ap
apa paragraph plus the blank lines after itSentences and paragraphs: is, as, ip and ap
gUi"uppercase the inside of a stringMix and match: any operator, any object
yi(yank the inside of parenthesesMix and match: any operator, any object
>iBindent the inside of a {} blockMix and match: any operator, any object
vi"select the inside of a stringMix and match: any operator, any object
va(select parentheses and their contentsMix and match: any operator, any object
{Visual}preplace the selection with the registerMix and match: any operator, any object

6Visual Mode

vstart (or stop) a characterwise selectionv, V and Ctrl-v: select, then act
Vstart (or stop) a linewise selectionv, V and Ctrl-v: select, then act
<C-v>start (or stop) a blockwise selectionv, V and Ctrl-v: select, then act
dVisual: delete the selectionv, V and Ctrl-v: select, then act
cVisual: change the selectionv, V and Ctrl-v: select, then act
UVisual: make the selection uppercasev, V and Ctrl-v: select, then act
uVisual: make the selection lowercasev, V and Ctrl-v: select, then act
<Esc>leave Visual mode without doing anythingv, V and Ctrl-v: select, then act
oVisual: jump to the other end of the selectionAdjust a selection: o and gv
OVisual block: jump to the other corner on the same lineAdjust a selection: o and gv
gvreselect the previous Visual areaAdjust a selection: o and gv
viwselect a word (any text object works after v)Adjust a selection: o and gv
.repeat the last change (after Visual: same-size area at the cursor)Repeat a Visual edit with .
>Visual: shift the selected lines (or block) rightRepeat a Visual edit with .
<Visual: shift the selected lines (or block) leftRepeat a Visual edit with .
{count}>Visual: shift right {count} timesRepeat a Visual edit with .
gU{motion}uppercase the text a motion or text object coversOperators repeat better than selections
gu{motion}lowercase the text a motion or text object coversOperators repeat better than selections
g~{motion}toggle case of the text a motion or text object coversOperators repeat better than selections
ci"change inside quotes (any c + text object repeats well)Operators repeat better than selections
<C-v>{move}I{text}<Esc>insert {text} before the block on every lineEdit a column: I, c and r on a block
<C-v>{move}c{text}<Esc>replace the block with {text} on every lineEdit a column: I, c and r on a block
r{char}Visual: replace every selected character with {char}Edit a column: I, c and r on a block
yypVr=underline a line (copy it, then turn the copy into =)Edit a column: I, c and r on a block
<C-v>{move}$A{text}<Esc>append {text} to the end of every selected lineAppend to ragged lines: $A
<C-v>{move}A{text}<Esc>append {text} just after the block on every lineAppend to ragged lines: $A
$Visual block: stretch the block to the end of every lineAppend to ragged lines: $A

7Registers

xcut the character under the cursorThe unnamed register: x, dd, yy and p
ddcut the whole lineThe unnamed register: x, dd, yy and p
yyyank (copy) the whole lineThe unnamed register: x, dd, yy and p
pput after the cursor (lines: below)The unnamed register: x, dd, yy and p
Pput before the cursor (lines: above)The unnamed register: x, dd, yy and p
xpswap two charactersThe unnamed register: x, dd, yy and p
ddpswap the line with the one belowThe unnamed register: x, dd, yy and p
yypduplicate the lineThe unnamed register: x, dd, yy and p
"{a-z}use register {a-z} for the next yank, delete or putNamed registers: "a to "z
"ayyyank the line into register aNamed registers: "a to "z
"apput register a after the cursorNamed registers: "a to "z
"Ayyappend the line to register a ("Add cuts and appends)Named registers: "a to "z
:reglist what every register holdsNamed registers: "a to "z
"0pput the most recent yank, even after deletesThe yank register "0 and the black hole "_
"_d{motion}delete without changing any registerThe yank register "0 and the black hole "_
"_dddelete the line into the black holeThe yank register "0 and the black hole "_
"1pput the most recent deleted line(s); "2p the delete before, …The yank register "0 and the black hole "_
"-pput the last small (within-a-line) deleteThe yank register "0 and the black hole "_
viwpreplace the word with the register; the old word goes to ""Replace a selection with p (and P)
Vpreplace the line(s) with the registerReplace a selection with p (and P)
v{motion}Preplace the selection and leave every register as it wasReplace a selection with p (and P)
v{motion}"0preplace the selection with the last yankReplace a selection with p (and P)
gplike p, but leave the cursor just after the new textMore ways to put: gp, ]p, counts and Ctrl-r
gPlike P, but leave the cursor just after the new textMore ways to put: gp, ]p, counts and Ctrl-r
]pput lines below, re-indented to match the current lineMore ways to put: gp, ]p, counts and Ctrl-r
[pput lines above, re-indented to match the current lineMore ways to put: gp, ]p, counts and Ctrl-r
{count}pput {count} copiesMore ways to put: gp, ]p, counts and Ctrl-r
<C-r>{reg}Insert mode: insert the contents of a registerMore ways to put: gp, ]p, counts and Ctrl-r

8Macros

q{a-z}start recording into a registerRecord and replay: q, @ and @@
qstop recordingRecord and replay: q, @ and @@
@{a-z}replay a registerRecord and replay: q, @ and @@
@@replay the register you ran lastRecord and replay: q, @ and @@
{count}@{a-z}replay a register {count} timesReplay with a count (and why too many is fine)
99@areplay until a command in the macro failsReplay with a count (and why too many is fine)
:%normal @arun register a on every lineRun a macro on many lines: :normal @a
:'<,'>normal @arun register a on each selected lineRun a macro on many lines: :normal @a
:g/{pattern}/normal @arun register a on each matching lineRun a macro on many lines: :normal @a
{Visual}@alinewise Visual: run register a on each selected linenvimRun a macro on many lines: :normal @a
q{A-Z}record, appending to a registerAdd to a macro: qA
:reg {a-z}show what a register holdsAdd to a macro: qA
<C-a>add 1 to the number under or after the cursorCounting with CTRL-A
<C-x>subtract 1 from the number under or after the cursorCounting with CTRL-A
{Visual}g<C-a>add 1, 2, 3… to the numbers of the selected linesCounting with CTRL-A
gvreselect the last Visual areaCounting with CTRL-A
"{a-z}pput a register after the cursorEdit a macro as text
:put {a-z}put a register on a new line belowEdit a macro as text
0"ay$yank the line into register a, without the line breakEdit a macro as text
"aYyank to the end of the line into register anvimEdit a macro as text

9Search & Patterns

/{pattern}<CR>search forward for {pattern}Search: / ? n and N
?{pattern}<CR>search backward for {pattern}Search: / ? n and N
nrepeat the last search in the same directionSearch: / ? n and N
Nrepeat the last search in the opposite directionSearch: / ? n and N
/<CR>search forward for the last pattern againSearch: / ? n and N
?<CR>search backward for the last pattern againSearch: / ? n and N
d/{pattern}<CR>delete up to (not including) the next matchSearch as a motion: d/ c/ d?
c/{pattern}<CR>change up to the next matchSearch as a motion: d/ c/ d?
d?{pattern}<CR>delete back to the previous match (keeps the cursor character)Search as a motion: d/ c/ d?
y/{pattern}<CR>yank up to the next matchSearch as a motion: d/ c/ d?
*search forward for the whole word under the cursorWhole words: * # g* and \< \>
#search backward for the whole word under the cursorWhole words: * # g* and \< \>
g*like *, but also matches inside longer wordsWhole words: * # g* and \< \>
g#like #, but also matches inside longer wordsWhole words: * # g* and \< \>
\<pattern: start of a wordWhole words: * # g* and \< \>
\>pattern: end of a wordWhole words: * # g* and \< \>
:%s//{new}substitute the last search pattern on every lineWhole words: * # g* and \< \>
\cpattern: ignore case for this searchCase: ignorecase, smartcase, \c and \C
\Cpattern: match case exactly for this searchCase: ignorecase, smartcase, \c and \C
:set ignorecaseignore case in searches (:set ic, :set noic)Case: ignorecase, smartcase, \c and \C
:set smartcasematch case when the pattern has a capital (:set scs)Case: ignorecase, smartcase, \c and \C
:s/{pat}/{new}/isubstitute ignoring case (I: match case)Case: ignorecase, smartcase, \c and \C
\vpattern: very magic (( ) | + ? { } work without backslashes)Very magic \v, very nomagic \V
\Vpattern: very nomagic (only \ and the delimiter are special)Very magic \v, very nomagic \V
\d \w \s \x \adigit, word char, space/tab, hex digit, letterVery magic \v, very nomagic \V
\u \luppercase letter, lowercase letterVery magic \v, very nomagic \V
\1:s replacement: the text the first group matchedVery magic \v, very nomagic \V
/<Up>recall an older search (that starts with what you typed)Very magic \v, very nomagic \V
/<Down>recall a newer searchVery magic \v, very nomagic \V
/{pat}/ecursor on the last character of the matchOffsets and match edges: /e, \zs, \ze
/{pat}/e+{n}{n} characters past the end (e-{n}: before it)Offsets and match edges: /e, \zs, \ze
/{pat}/s-{n}{n} characters before the start (also b-{n}, s+{n})Offsets and match edges: /e, \zs, \ze
/{pat}/+{n}start of the line {n} lines below the match (-{n}: above)Offsets and match edges: /e, \zs, \ze
//elast pattern again, with a new offsetOffsets and match edges: /e, \zs, \ze
\zspattern: the match starts hereOffsets and match edges: /e, \zs, \ze
\zepattern: the match ends hereOffsets and match edges: /e, \zs, \ze
gnselect the next match (or the one under the cursor)gn: edit match after match
gNselect the previous matchgn: edit match after match
cgnchange the next match; . repeats on the following onegn: edit match after match
dgndelete the next match; . repeatsgn: edit match after match
:%s/{pat}//gncount the matches without changing anythinggn: edit match after match

10Ex Commands

:{N}jump to line NLine ranges: :d, :j and friends
:{N},{M}ddelete lines N to MLine ranges: :d, :j and friends
:.,$ddelete from the cursor line to the endLine ranges: :d, :j and friends
:.,+{N}ddelete the cursor line and the N below itLine ranges: :d, :j and friends
:{N},{M}jjoin lines N to M into oneLine ranges: :d, :j and friends
:{N},{M}j!join lines without adding spacesLine ranges: :d, :j and friends
:'<,'>range of the last Visual selectionLine ranges: :d, :j and friends
:%range of the whole fileLine ranges: :d, :j and friends
:t.duplicate the cursor lineCopy and move lines: :t and :m
:{N}t.copy line N below the cursorCopy and move lines: :t and :m
:t$copy the cursor line to the endCopy and move lines: :t and :m
:t0copy the cursor line to the topCopy and move lines: :t and :m
:m0move the cursor line to the topCopy and move lines: :t and :m
:m$move the cursor line to the endCopy and move lines: :t and :m
:m+1move the cursor line down oneCopy and move lines: :t and :m
:m-2move the cursor line up oneCopy and move lines: :t and :m
:%normal {keys}run Normal-mode keys on every lineNormal mode on many lines: :normal
:'<,'>normal {keys}run them on each selected lineNormal mode on many lines: :normal
:{range}normal .repeat the last change on each lineNormal mode on many lines: :normal
:s/{old}/{new}/replace the first match on the lineSubstitute: :s, ranges and flags
:s/{old}/{new}/greplace every match on the lineSubstitute: :s, ranges and flags
:%s/{old}/{new}/greplace every match in the fileSubstitute: :s, ranges and flags
:'<,'>s/{old}/{new}/replace in the selected linesSubstitute: :s, ranges and flags
&in the replacement: the whole matchSubstitute: :s, ranges and flags
\&in the replacement: a literal &Substitute: :s, ranges and flags
:g/{pattern}/ddelete every matching lineMatching lines: :g, :v and :sort
:v/{pattern}/ddelete every line that does not matchMatching lines: :g, :v and :sort
:g/^/m0reverse the order of the linesMatching lines: :g, :v and :sort
:g/{pattern}/t$copy every matching line to the endMatching lines: :g, :v and :sort
:sortsort linesMatching lines: :g, :v and :sort
:sort usort and drop duplicatesMatching lines: :g, :v and :sort
:sort nsort by the first numberMatching lines: :g, :v and :sort
:sort!sort in reverseMatching lines: :g, :v and :sort
@:repeat the last command lineRepeat the last Ex command: @: and @@
{count}@:repeat it {count} timesRepeat the last Ex command: @: and @@
@@repeat the last @ command (including @:)Repeat the last Ex command: @: and @@
<C-r><C-w>command line: insert the word under the cursorGrab the word under the cursor: <C-r><C-w>
<C-r><C-a>command line: insert the WORD under the cursorGrab the word under the cursor: <C-r><C-w>
<C-r><C-l>command line: insert the cursor lineGrab the word under the cursor: <C-r><C-w>
<C-r>{register}command line: insert a registerGrab the word under the cursor: <C-r><C-w>

11Windows & Tabs

<C-w>ssplit the window: new one above (also :sp)Split the screen: <C-w>s, <C-w>v, :sp, :vs
<C-w>vsplit vertically: new one on the left (also :vs)Split the screen: <C-w>s, <C-w>v, :sp, :vs
:sp {file}open {file} in a new window aboveSplit the screen: <C-w>s, <C-w>v, :sp, :vs
:vs {file}open {file} in a new window on the leftSplit the screen: <C-w>s, <C-w>v, :sp, :vs
<C-w>nnew window on an empty buffer (also :new)Split the screen: <C-w>s, <C-w>v, :sp, :vs
:vnewlike :new, but side by sideSplit the screen: <C-w>s, <C-w>v, :sp, :vs
:wincmd {key}run <C-w>{key} as an ex commandSplit the screen: <C-w>s, <C-w>v, :sp, :vs
<C-w>hgo to the window on the leftMove between windows: <C-w>h j k l, w, p
<C-w>jgo to the window belowMove between windows: <C-w>h j k l, w, p
<C-w>kgo to the window aboveMove between windows: <C-w>h j k l, w, p
<C-w>lgo to the window on the rightMove between windows: <C-w>h j k l, w, p
<C-w>wnext window (wraps around); also <C-w><C-w>Move between windows: <C-w>h j k l, w, p
<C-w>Wprevious window (wraps around)Move between windows: <C-w>h j k l, w, p
{N}<C-w>wgo to window N (numbered top-left to bottom-right)Move between windows: <C-w>h j k l, w, p
<C-w>tgo to the top-left windowMove between windows: <C-w>h j k l, w, p
<C-w>bgo to the bottom-right windowMove between windows: <C-w>h j k l, w, p
<C-w>pgo back to the previous windowMove between windows: <C-w>h j k l, w, p
<C-w>cclose the current window (also :close)Close windows: <C-w>c, <C-w>o
<C-w>qquit the window; in the last window this quits Neovim (also :q)Close windows: <C-w>c, <C-w>o
{N}<C-w>cclose window N, stay where you areClose windows: <C-w>c, <C-w>o
<C-w>oclose all other windows (also :only)Close windows: <C-w>c, <C-w>o
{N}<C-w>okeep only window NClose windows: <C-w>c, <C-w>o
<C-w>xexchange with the next window in the row/columnRearrange windows: <C-w>x, <C-w>r, <C-w>H J K L
<C-w>rrotate windows down/right; the cursor moves with its windowRearrange windows: <C-w>x, <C-w>r, <C-w>H J K L
<C-w>Rrotate windows up/leftRearrange windows: <C-w>x, <C-w>r, <C-w>H J K L
<C-w>Hmove the window to the far left, full heightRearrange windows: <C-w>x, <C-w>r, <C-w>H J K L
<C-w>Jmove the window to the bottom, full widthRearrange windows: <C-w>x, <C-w>r, <C-w>H J K L
<C-w>Kmove the window to the top, full widthRearrange windows: <C-w>x, <C-w>r, <C-w>H J K L
<C-w>Lmove the window to the far right, full heightRearrange windows: <C-w>x, <C-w>r, <C-w>H J K L
<C-w>=make all windows (almost) the same sizeRearrange windows: <C-w>x, <C-w>r, <C-w>H J K L
<C-w>_make the window as tall as possibleRearrange windows: <C-w>x, <C-w>r, <C-w>H J K L
<C-w>|make the window as wide as possibleRearrange windows: <C-w>x, <C-w>r, <C-w>H J K L
:tabe {file}open {file} in a new tab after the current oneTab pages: :tabe, gt, gT, <C-w>T
:tabnewopen a new tab with an empty bufferTab pages: :tabe, gt, gT, <C-w>T
gtnext tab (wraps around); also :tabnTab pages: :tabe, gt, gT, <C-w>T
gTprevious tab (wraps around); also :tabpTab pages: :tabe, gt, gT, <C-w>T
{N}gtgo to tab NTab pages: :tabe, gt, gT, <C-w>T
<C-w>Tmove the current window into a new tabTab pages: :tabe, gt, gT, <C-w>T
:tabcclose the current tab (:tabc N closes tab N)Tab pages: :tabe, gt, gT, <C-w>T
:taboclose all other tabsTab pages: :tabe, gt, gT, <C-w>T
:tabm {N}move this tab after tab N (0 = first, none = last)Tab pages: :tabe, gt, gT, <C-w>T

12Neovim Extras

Yyank from the cursor to the end of the line (y$)nvimWhat Neovim changes: Y and saner defaults
yyyank the whole lineWhat Neovim changes: Y and saner defaults
{count}<C-a>add count to the number at or after the cursor (007 is decimal)nvimWhat Neovim changes: Y and saner defaults
{count}<C-x>subtract count from the number at or after the cursornvimWhat Neovim changes: Y and saner defaults
<C-l>redraw and clear search highlightingnvimWhat Neovim changes: Y and saner defaults
[<Space>add [count] empty lines above the cursor linenvimRoom to breathe: [<Space> and ]<Space>
]<Space>add [count] empty lines below the cursor linenvimRoom to breathe: [<Space> and ]<Space>
.repeat the last change, including theseRoom to breathe: [<Space> and ]<Space>
gcctoggle comments on [count] linesnvimComment lines: gcc and gc{motion}
gc{motion}toggle comments on the lines {motion} coversnvimComment lines: gcc and gc{motion}
{Visual}gctoggle comments on the selected linesnvimComment lines: gcc and gc{motion}
.repeat the last gcComment lines: gcc and gc{motion}
gcgcuncomment the comment block around the cursornvimComment blocks: gcgc, dgc and ygc
dgcdelete the comment block around the cursornvimComment blocks: gcgc, dgc and ygc
ygcyank the comment block around the cursornvimComment blocks: gcgc, dgc and ygc
{Visual}gctoggle comments on the selected linesnvimComment blocks: gcgc, dgc and ygc
{Visual}*search forward for the selected textnvimSearch for the selection: Visual * and #
{Visual}#search backward for the selected textnvimSearch for the selection: Visual * and #
n / Nnext / previous match of the last searchSearch for the selection: Visual * and #
:%s//{new}/greplace every match of the last searchSearch for the selection: Visual * and #
&repeat the last :s on this line, keeping its flags (:&&)nvim&: repeat the last substitution
{count}&repeat it on count lines from the cursornvim&: repeat the last substitution
:[range]&&repeat the last :s on a range, keeping its flags&: repeat the last substitution
:[range]&repeat the last :s without its flags&: repeat the last substitution
Qreplay the last recorded register [count] timesnvimQ: replay the last recording
{Visual}Qlinewise Visual: replay it once on each selected linenvimQ: replay the last recording
{Visual}@{reg}linewise Visual: run register {reg} on each selected linenvimQ: replay the last recording
q{reg} … qrecord a macro into {reg}Q: replay the last recording
outside the editor the page is in normal mode: ? keymaps · / find · : commandsfound this useful? ☕ support it ·credits · source · not affiliated with Vim or Neovim