Neovim Cheat Sheet

Neovim Cheat Sheet


Basics
Command
Mode
Description
:help
ex
Open a help window
:quit
ex
Quit current window (when one window quit vim)
:wq
ex
Write to a file and quit window or vim
:write
ex
Write to a file
Buffers
Command
Mode
Description
:bdelete
ex
Remove a buffer from the buffer list
:bnext
ex
Go to next buffer in the buffer list
:bprevious
ex
Go to previous buffer in the buffer list
:ls
ex
List all buffers
Changes
Command
Mode
Description
:changes
ex
Print the change list
[n] g,
n
Go to n newer position in change list
[n] g;
n
Go to n older position in change list
Cursor Horizontal
Command
Mode
Description
[n] $
n
Cursor to the end of nth next line
0
n
Cursor to the first char of the line
[n] B
n
Cursor n words backward
[n] E
n
Cursor forward to the end of word n
[n] W
n
Cursor n words forward
^
n
Cursor to the first char of the line
[n] b
n
Cursor n words backward
[n] e
n
Cursor forward to the end of word n
g_
n
Cursor to the last char n - 1 lines lower
[n] h
n
Cursor n chars to the left
[n] l
n
Cursor n chars to the right
[n] w
n
Cursor n words forward
Cursor Vertical
Command
Mode
Description
[n] G
n
Cursor to line n, default last line
[n] H
n
Cursor to line n from top of screen
[n] L
n
Cursor to line n from bottom of screen
M
n
Cursor to middle line of screen
[n] gg
n
Cursor to line n, default first line
[n] j
n
Cursor n lines downward
[n] k
n
Cursor n lines upward
Cut And Paste
Command
Mode
Description
[n] D
n
Delete the characters under the cursor until the end of the line and n-1 more lines [into register x]; synonym for "d$"
[n] P
n
Paste before the cursor
[n] Y
n
Yank to end of current line
d$
n
Delete to end of current line
[n] dd
n
Delete the current line
diw
n
Delete inner word
[n] p
n
Put the text [from register x] after the cursor n times
[n] x
n
Delete n characters under and after the cursor [into register x]
y$
n
Yank to end of current line
yiw
n
Yank inner word
[n] yy
n
Yank the current line
Editing
Command
Mode
Description
J
n
Join n lines; default is 2
R
n
Enter replace mode: overtype existing characters, repeat the entered text n-1 times
gJ
n
Join lines without inserting space
gwip
n
Reflow the current paragraph
[n] r{char}
n
Replace n chars with {char}
u
n
Undo changes
Folds
Command
Mode
Description
zC
n
Close folds recursively
zO
n
Open folds recursively
zR
n
Set 'foldlevel' to the deepest fold
za
n
Open a closed fold, close an open fold
zc
n
Close a fold
zm
n
Subtract one from 'foldlevel'
zo
n
Open fold
zr
n
Add one to 'foldlevel'
Insert Mode
Command
Mode
Description
[n] A
n
Append text after the end of the line n times
[n] C
n
Change from the cursor position to the end of the line, and n-1 more lines [into register x]; synonym for "c$"
[n] I
n
Insert text before the first char on the line n times
[n] O
n
Begin a new line above the cursor and insert text, repeat n times
[n] S
n
Delete n lines [into register x] and start insert; synonym for "cc".
[n] a
n
Append text after the cursor n times
c$
n
Delete from the cursor position to the end of the line, and enter insert mode
[n] cc
n
Delete the current line then enter insert mode
ce
n
Delete from the cursor position to the end of the current word, and enter insert mode
ciw
n
Delete the current inner-word, and enter insert mode
cw
n
Delete from the cursor position to the end of the current word, and enter insert mode
[n] i
n
Insert text before the cursor n times
[n] o
n
Begin a new line below the cursor and insert text, repeat n times
[n] s
n
(substitute) delete n characters [into register x] and start insert
Jumps
Command
Mode
Description
:jumps
ex
Print the jump list
C-I
n
Same as <tab>
C-O
n
Jump one step backward within jump list
`"
n
Go the position of the most recent edit prior to saving this file
``
n
Cursor to the position before latest jump
Macros
Command
Mode
Description
[n] @@
n
Repeat the previous @{a-z} n times
[n] @{a-z}
n
Execute the contents of register {a-z} n times
q
n
(while recording) stops recording
q{0-9a-zA-Z"}
n
Record typed characters into named register {0-9a-za-z"} (uppercase to append)
Marks
Command
Mode
Description
'x
n
Jump to the start of the line containing mark x
:marks
ex
List all marks
`x
n
Jump to mark x
Paging
Command
Mode
Description
C-B
n
Move screen up one page
C-D
n
Move cursor down one-half page
C-F
n
Move screen down one page
C-U
n
Move cursor up one-half page
Registers
Command
Mode
Description
:registers
ex
Display the contents of registers
p
n
Put the text [from register x] after the cursor n times
y
n
Yank operator
Visual Mode
Command
Mode
Description
Esc
v
Return to normal mode
O
v
Move horizontally to other corner of area
aB
v
Extend highlighted area with a {} block
ab
v
Extend highlighted area with a () block
at
v
Extend highlighted area with a tag block
aw
v
Extend highlighted area with "a word"
iB
v
Extend highlighted area with inner {} block
ib
v
Extend highlighted area with inner () block
it
v
Extend highlighted area with inner tag block
o
v
Move cursor to other corner of area
Windows
Command
Mode
Description
[n] C-W h
n
Go to nth left window (stop at first window)
[n] C-W j
n
Go n windows down (stop at last window)
[n] C-W k
n
Go n windows up (stop at first window)
[n] C-W l
n
Go to nth right window (stop at last window)
[n] C-W s
n
Split current window in two parts, new window n lines high
[n] C-W v
n
Split current window vertically, new window n columns wide
[n] C-W x
n
Exchange current window with window n (default: next window)