Neovim Cheat Sheet



Basics

CommandAction
:helpopen a help window
:writewrite to a file
:wqwrite to a file and quit window or Vim
:quitquit current window (when one window quit Vim)

Cursor Movement

Horizontal

CommandAction
[n] hcursor N chars to the left
[n] lcursor N chars to the right
[n] wcursor N words forward
[n] Wcursor N WORDS forward
[n] ecursor forward to the end of word N
[n] Ecursor forward to the end of WORD N
[n] bcursor N words backward
[n] Bcursor N WORDS backward
0cursor to the first char of the line
^cursor to the first CHAR of the line
[n] $cursor to the end of Nth next line
g_cursor to the last CHAR N - 1 lines lower

Vertical

CommandAction
[n] jcursor N lines downward
[n] kcursor N lines upward
[n] Hcursor to line N from top of screen
Mcursor to middle line of screen
[n] Lcursor to line N from bottom of screen
[n] ggcursor to line N, default first line
[n] Gcursor to line N, default last line

Paging

CommandAction
C-DMove cursor down one-half page
C-UMove cursor up one-half page
C-BMove screen up one page
C-FMove screen down one page

Insert Mode

CommandAction
[n] iinsert text before the cursor N times
[n] Iinsert text before the first CHAR on the line N times
[n] aappend text after the cursor N times
[n] Aappend text after the end of the line N times
[n] obegin a new line below the cursor and insert text, repeat N times
[n] Obegin a new line above the cursor and insert text, repeat N times
[n] ccDelete the current line then enter INSERT mode
[n] Cchange from the cursor position to the end of the line, and N-1 more lines [into register x]; synonym for "c$"
c$Delete from the cursor position to the end of the line, and enter INSERT mode
cwDelete from the cursor position to the end of the current word, and enter INSERT mode
ceDelete from the cursor position to the end of the current word, and enter INSERT mode
ciwDelete the current inner-word, and enter INSERT mode
[n] s(substitute) delete N characters [into register x] and start insert
[n] Sdelete N lines [into register x] and start insert; synonym for "cc".

Visual Mode

CommandAction
omove cursor to other corner of area
Omove horizontally to other corner of area
EscReturn to NORMAL mode
awextend highlighted area with "a word"
abextend highlighted area with a () block
aBextend highlighted area with a {} block
atextend highlighted area with a tag block
ibextend highlighted area with inner () block
iBextend highlighted area with inner {} block
itextend highlighted area with inner tag block

Editing

CommandAction
[n] r{char}replace N chars with {char}
Renter replace mode: overtype existing characters, repeat the entered text N-1 times
JJoin N lines; default is 2
gJjoin lines without inserting space
gwipReflow the current paragraph
uundo changes

Cut & Paste

CommandAction
[n] yyYank the current line
yiwYank inner word
y$Yank to end of current line
[n] YYank to end of current line
[n] pput the text [from register x] after the cursor N times
[n] PPaste before the cursor
[n] ddDelete the current line
diwDelete inner word
d$Delete to end of current line
[n] Ddelete the characters under the cursor until the end of the line and N-1 more lines [into register x]; synonym for "d$"
[n] xdelete N characters under and after the cursor [into register x]

Registers

CommandAction
:registersdisplay the contents of registers
yyank operator
pput the text [from register x] after the cursor N times

Marks

CommandAction
:markslist all marks
`xJump to mark x
'xJump to the start of the line containing mark x

Jumps

CommandAction
:jumpsprint the jump list
C-Isame as <Tab>
C-OJump one step backward within jump list
``cursor to the position before latest jump
`"Go the position of the most recent edit prior to saving this file

Changes

CommandAction
:changesprint the change list
[n] g,go to N newer position in change list
[n] g;go to N older position in change list

Macros

CommandAction
q{0-9a-zA-Z"}record typed characters into named register {0-9a-zA-Z"} (uppercase to append)
q(while recording) stops recording
[n] @{a-z}execute the contents of register {a-z} N times
[n] @@repeat the previous @{a-z} N times

Buffers

CommandAction
:bnextgo to next buffer in the buffer list
:bpreviousgo to previous buffer in the buffer list
:bdeleteremove a buffer from the buffer list
:lslist all buffers

Windows

CommandAction
[n] C-W ssplit current window in two parts, new window N lines high
[n] C-W vsplit current window vertically, new window N columns wide
[n] C-W hgo to Nth left window (stop at first window)
[n] C-W jgo N windows down (stop at last window)
[n] C-W kgo N windows up (stop at first window)
[n] C-W lgo to Nth right window (stop at last window)
[n] C-W xexchange current window with window N (default: next window)

Folds

CommandAction
zaopen a closed fold, close an open fold
zmsubtract one from 'foldlevel'
zoopen fold
zOopen folds recursively
zcclose a fold
zCclose folds recursively
zradd one to 'foldlevel'
zRset 'foldlevel' to the deepest fold