cheat sheet
Every key taught in the drills, generated from the lessons. Click a key's lesson to practise it.
415 keys
1Moving Around
h | left one characterh j k l, and counts |
j | down one lineh j k l, and counts |
k | up one lineh j k l, and counts |
l | right one characterh j k l, and counts |
{count}j | down {count} lines, e.g. 4j (read the count from the gutter)h j k l, and counts |
{count}k | up {count} linesh j k l, and counts |
{count}{motion} | repeat any motion {count} times, e.g. 3lh j k l, and counts |
w | start of the next wordWords and WORDS: w b e ge, W B E gE |
b | back to the start of a wordWords and WORDS: w b e ge, W B E gE |
e | end of the wordWords and WORDS: w b e ge, W B E gE |
ge | back to the end of the previous wordWords and WORDS: w b e ge, W B E gE |
W | start of the next WORD (whitespace-separated)Words and WORDS: w b e ge, W B E gE |
B | back to the start of a WORDWords and WORDS: w b e ge, W B E gE |
E | end of the WORDWords and WORDS: w b e ge, W B E gE |
gE | back to the end of the previous WORDWords and WORDS: w b e ge, W B E gE |
0 | first 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 | |
gg | first line of the fileThe whole file: gg, G, {n}G and :{n} |
G | last line of the fileThe whole file: gg, G, {n}G and :{n} |
{count}G | line {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: { } ( ) |
H | top line of the window ({count}H: count from the top)The screen: H M L, scrolling and zz |
M | middle line of the windowThe screen: H M L, scrolling and zz |
L | bottom 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 |
zz | scroll so the cursor line is in the middleThe screen: H M L, scrolling and zz |
zt | scroll so the cursor line is at the topThe screen: H M L, scrolling and zz |
zb | scroll 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
i | insert before the cursorDoors into Insert mode: i, a, I, A, o, O |
a | append after the cursorDoors into Insert mode: i, a, I, A, o, O |
I | insert before the first non-blank of the lineDoors into Insert mode: i, a, I, A, o, O |
A | append at the end of the lineDoors into Insert mode: i, a, I, A, o, O |
o | open a new line below and insertDoors into Insert mode: i, a, I, A, o, O |
O | open a new line above and insertDoors into Insert mode: i, a, I, A, o, O |
gi | insert 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 |
R | Replace 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>0 | insert 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
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 ' |
:marks | list 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 |
:jumps | show 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, |
:changes | show the change listThe change list: g; and g, |
5Text Objects
iw | inner word: the word under the cursorWords: iw, aw, iW and aW |
aw | a word: the word plus the space after it (or before)Words: iw, aw, iW and aW |
iW | inner WORD: everything up to the surrounding spacesWords: iw, aw, iW and aW |
aW | a WORD plus its spaceWords: iw, aw, iW and aW |
ciw | change the word under the cursorWords: iw, aw, iW and aW |
daw | delete 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< |
it | inner tag: the element's contentsTags: it and at |
at | a tag: the whole element with its tagsTags: it and at |
cit | change the element's contentsTags: it and at |
dat | delete the whole elementTags: it and at |
2it | the contents of the element one level outTags: it and at |
is | inner sentenceSentences and paragraphs: is, as, ip and ap |
as | a sentence plus the space after itSentences and paragraphs: is, as, ip and ap |
ip | inner paragraph: the lines up to a blank lineSentences and paragraphs: is, as, ip and ap |
ap | a 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 |
>iB | indent 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}p | replace the selection with the registerMix and match: any operator, any object |
6Visual Mode
v | start (or stop) a characterwise selectionv, V and Ctrl-v: select, then act |
V | start (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 |
d | Visual: delete the selectionv, V and Ctrl-v: select, then act |
c | Visual: change the selectionv, V and Ctrl-v: select, then act |
U | Visual: make the selection uppercasev, V and Ctrl-v: select, then act |
u | Visual: 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 |
o | Visual: jump to the other end of the selectionAdjust a selection: o and gv |
O | Visual block: jump to the other corner on the same lineAdjust a selection: o and gv |
gv | reselect the previous Visual areaAdjust a selection: o and gv |
viw | select 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
x | cut the character under the cursorThe unnamed register: x, dd, yy and p |
dd | cut the whole lineThe unnamed register: x, dd, yy and p |
yy | yank (copy) the whole lineThe unnamed register: x, dd, yy and p |
p | put after the cursor (lines: below)The unnamed register: x, dd, yy and p |
P | put before the cursor (lines: above)The unnamed register: x, dd, yy and p |
xp | swap two charactersThe unnamed register: x, dd, yy and p |
ddp | swap the line with the one belowThe unnamed register: x, dd, yy and p |
yyp | duplicate 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 |
"ayy | yank the line into register aNamed registers: "a to "z |
"ap | put register a after the cursorNamed registers: "a to "z |
"Ayy | append the line to register a ("Add cuts and appends)Named registers: "a to "z |
:reg | list what every register holdsNamed registers: "a to "z |
"0p | put 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 "_ |
"_dd | delete the line into the black holeThe yank register "0 and the black hole "_ |
"1p | put the most recent deleted line(s); "2p the delete before, …The yank register "0 and the black hole "_ |
"-p | put the last small (within-a-line) deleteThe yank register "0 and the black hole "_ |
viwp | replace the word with the register; the old word goes to ""Replace a selection with p (and P) |
Vp | replace the line(s) with the registerReplace a selection with p (and P) |
v{motion}P | replace the selection and leave every register as it wasReplace a selection with p (and P) |
v{motion}"0p | replace the selection with the last yankReplace a selection with p (and P) |
gp | like p, but leave the cursor just after the new textMore ways to put: gp, ]p, counts and Ctrl-r |
gP | like P, but leave the cursor just after the new textMore ways to put: gp, ]p, counts and Ctrl-r |
]p | put lines below, re-indented to match the current lineMore ways to put: gp, ]p, counts and Ctrl-r |
[p | put lines above, re-indented to match the current lineMore ways to put: gp, ]p, counts and Ctrl-r |
{count}p | put {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 @@ |
q | stop 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@a | replay until a command in the macro failsReplay with a count (and why too many is fine) |
:%normal @a | run register a on every lineRun a macro on many lines: :normal @a |
:'<,'>normal @a | run register a on each selected lineRun a macro on many lines: :normal @a |
:g/{pattern}/normal @a | run register a on each matching lineRun a macro on many lines: :normal @a |
{Visual}@a | linewise 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 |
gv | reselect the last Visual areaCounting with CTRL-A |
"{a-z}p | put 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 |
"aY | yank 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 |
n | repeat the last search in the same directionSearch: / ? n and N |
N | repeat 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 \< \> |
\c | pattern: ignore case for this searchCase: ignorecase, smartcase, \c and \C |
\C | pattern: match case exactly for this searchCase: ignorecase, smartcase, \c and \C |
:set ignorecase | ignore case in searches (:set ic, :set noic)Case: ignorecase, smartcase, \c and \C |
:set smartcase | match case when the pattern has a capital (:set scs)Case: ignorecase, smartcase, \c and \C |
:s/{pat}/{new}/i | substitute ignoring case (I: match case)Case: ignorecase, smartcase, \c and \C |
\v | pattern: very magic (( ) | + ? { } work without backslashes)Very magic \v, very nomagic \V |
\V | pattern: very nomagic (only \ and the delimiter are special)Very magic \v, very nomagic \V |
\d \w \s \x \a | digit, word char, space/tab, hex digit, letterVery magic \v, very nomagic \V |
\u \l | uppercase 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}/e | cursor 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 |
//e | last pattern again, with a new offsetOffsets and match edges: /e, \zs, \ze |
\zs | pattern: the match starts hereOffsets and match edges: /e, \zs, \ze |
\ze | pattern: the match ends hereOffsets and match edges: /e, \zs, \ze |
gn | select the next match (or the one under the cursor)gn: edit match after match |
gN | select the previous matchgn: edit match after match |
cgn | change the next match; . repeats on the following onegn: edit match after match |
dgn | delete the next match; . repeatsgn: edit match after match |
:%s/{pat}//gn | count the matches without changing anythinggn: edit match after match |
10Ex Commands
:{N} | jump to line NLine ranges: :d, :j and friends |
:{N},{M}d | delete lines N to MLine ranges: :d, :j and friends |
:.,$d | delete from the cursor line to the endLine ranges: :d, :j and friends |
:.,+{N}d | delete the cursor line and the N below itLine ranges: :d, :j and friends |
:{N},{M}j | join 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 |
:t0 | copy the cursor line to the topCopy and move lines: :t and :m |
:m0 | move 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+1 | move the cursor line down oneCopy and move lines: :t and :m |
:m-2 | move 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}/g | replace every match on the lineSubstitute: :s, ranges and flags |
:%s/{old}/{new}/g | replace 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}/d | delete every matching lineMatching lines: :g, :v and :sort |
:v/{pattern}/d | delete every line that does not matchMatching lines: :g, :v and :sort |
:g/^/m0 | reverse 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 |
:sort | sort linesMatching lines: :g, :v and :sort |
:sort u | sort and drop duplicatesMatching lines: :g, :v and :sort |
:sort n | sort 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>s | split the window: new one above (also :sp)Split the screen: <C-w>s, <C-w>v, :sp, :vs |
<C-w>v | split 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>n | new window on an empty buffer (also :new)Split the screen: <C-w>s, <C-w>v, :sp, :vs |
:vnew | like :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>h | go to the window on the leftMove between windows: <C-w>h j k l, w, p |
<C-w>j | go to the window belowMove between windows: <C-w>h j k l, w, p |
<C-w>k | go to the window aboveMove between windows: <C-w>h j k l, w, p |
<C-w>l | go to the window on the rightMove between windows: <C-w>h j k l, w, p |
<C-w>w | next window (wraps around); also <C-w><C-w>Move between windows: <C-w>h j k l, w, p |
<C-w>W | previous window (wraps around)Move between windows: <C-w>h j k l, w, p |
{N}<C-w>w | go to window N (numbered top-left to bottom-right)Move between windows: <C-w>h j k l, w, p |
<C-w>t | go to the top-left windowMove between windows: <C-w>h j k l, w, p |
<C-w>b | go to the bottom-right windowMove between windows: <C-w>h j k l, w, p |
<C-w>p | go back to the previous windowMove between windows: <C-w>h j k l, w, p |
<C-w>c | close the current window (also :close)Close windows: <C-w>c, <C-w>o |
<C-w>q | quit the window; in the last window this quits Neovim (also :q)Close windows: <C-w>c, <C-w>o |
{N}<C-w>c | close window N, stay where you areClose windows: <C-w>c, <C-w>o |
<C-w>o | close all other windows (also :only)Close windows: <C-w>c, <C-w>o |
{N}<C-w>o | keep only window NClose windows: <C-w>c, <C-w>o |
<C-w>x | exchange with the next window in the row/columnRearrange windows: <C-w>x, <C-w>r, <C-w>H J K L |
<C-w>r | rotate windows down/right; the cursor moves with its windowRearrange windows: <C-w>x, <C-w>r, <C-w>H J K L |
<C-w>R | rotate windows up/leftRearrange windows: <C-w>x, <C-w>r, <C-w>H J K L |
<C-w>H | move the window to the far left, full heightRearrange windows: <C-w>x, <C-w>r, <C-w>H J K L |
<C-w>J | move the window to the bottom, full widthRearrange windows: <C-w>x, <C-w>r, <C-w>H J K L |
<C-w>K | move the window to the top, full widthRearrange windows: <C-w>x, <C-w>r, <C-w>H J K L |
<C-w>L | move 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 |
:tabnew | open a new tab with an empty bufferTab pages: :tabe, gt, gT, <C-w>T |
gt | next tab (wraps around); also :tabnTab pages: :tabe, gt, gT, <C-w>T |
gT | previous tab (wraps around); also :tabpTab pages: :tabe, gt, gT, <C-w>T |
{N}gt | go to tab NTab pages: :tabe, gt, gT, <C-w>T |
<C-w>T | move the current window into a new tabTab pages: :tabe, gt, gT, <C-w>T |
:tabc | close the current tab (:tabc N closes tab N)Tab pages: :tabe, gt, gT, <C-w>T |
:tabo | close 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
Y | yank from the cursor to the end of the line (y$)nvimWhat Neovim changes: Y and saner defaults |
yy | yank 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> |
gcc | toggle comments on [count] linesnvimComment lines: gcc and gc{motion} |
gc{motion} | toggle comments on the lines {motion} coversnvimComment lines: gcc and gc{motion} |
{Visual}gc | toggle comments on the selected linesnvimComment lines: gcc and gc{motion} |
. | repeat the last gcComment lines: gcc and gc{motion} |
gcgc | uncomment the comment block around the cursornvimComment blocks: gcgc, dgc and ygc |
dgc | delete the comment block around the cursornvimComment blocks: gcgc, dgc and ygc |
ygc | yank the comment block around the cursornvimComment blocks: gcgc, dgc and ygc |
{Visual}gc | toggle 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 / N | next / previous match of the last searchSearch for the selection: Visual * and # |
:%s//{new}/g | replace 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 |
Q | replay the last recorded register [count] timesnvimQ: replay the last recording |
{Visual}Q | linewise 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} … q | record a macro into {reg}Q: replay the last recording |