Neovim Cheatsheet

https://neovim.io/

Modes

Esc
Normal: navigate and run commands; Esc returns from Insert, Visual or Command-line mode
ia
Insert: type text before / after the cursor
v
Visual: select characters
V
Visual line: select whole lines
C-v
Visual block: select a rectangle
:
Command-line: enter an Ex command

General & Desktop

C-sIV
Save buffer (:w)
C-aV
Select all (ggVG)
C-z
Undo
C-r
Redo
C-lV
Select whole line (V)
A-C-dIV
Duplicate line
Esc Esc
Clear search highlight (:noh)
F1
Help (:h)
F3
Toggle search highlighting
F4
Quit window (:q)
F6
Toggle word wrap
F7I
Insert ISO datetime
F10
Edit init.lua config
F11
Show active keymaps (Snacks)

Navigation & Motions

HomeIV
Smart Home (first non-blank / 0)
EndIV
Smart End ($ / past last char)
WV
Next subword start (Spider)
BV
Prev subword start (Spider)
EV
Next subword end (Spider)
g EV
Prev subword end (Spider)
A-C-RightIV
Spider subword forward
A-C-LeftIV
Spider subword backward
z hz l
Scroll view left / right (z-Left / z-Right)
z Hz L
Scroll half-screen left / right
z sz e
Scroll cursor to screen start / end
%
Matching pair ((), {}, [])
] u[ u
Next / prev URL
g x
Open URL or file under cursor

Hop & Text Objects

s␣ w V
Hop Word
SV
Hop Line Start
g sV
Hop 2 characters
␣ j␣ k
Hop Vertical
i SV
Inner subword object
a SV
Outer subword object
i ma m V
Treesitter function inner / outer
i ca c V
Treesitter class inner / outer
a sV
Treesitter local scope object
g aV
EasyAlign text

Line & Black-Hole Editing

A-UpA-Down
Move line up / down
F8[ ␣
Insert blank line above, keep cursor
F9] ␣
Insert blank line below, keep cursor
DelV
Delete char (no clipboard "_x)
BS
Delete char back (no clip "_X)
C-DelC-S-k V
Delete line (no clip "_dd)
A-BSI
Delete word backward (no clip)
A-DelI
Delete word forward (no clip)
A-S-BSI
Delete subword back (Spider)
A-S-DelI
Delete subword forward (Spider)
c W
Change to end of subword
TabS-Tab V
Indent / unindent (retains selection)

Clipboard & Native Marks

C-A-cV
Copy (y)
C-A-xV
Cut (d)
C-A-vIV
Paste (system clipboard)
m a` a
Set / jump buffer mark
m A` A
Set / jump global mark (across files)
` '
Jump before last jump
` .
Jump to last edit
` ^
Jump to last exited insert mode
` [` ]
Jump to start / end of last yank

Multiple Cursors & Surround

C-n
Select word / next occurrence
␣ a
Select all occurrences
␣ v /
Start regex search
␣ v c
Add cursor at position
␣ v g
Reselect last session
␣ v aV
Add visual selection as a region
␣ v AV
Select all occurrences of visual selection
␣ v cV
Create a column of cursors
␣ v fV
Find patterns in visual selection
␣ v /V
Find a regex in visual selection
␣ v s␣ v rV
Remove regions inside / outside selection (active VM session)
C-S-DownC-S-Up
Goto next / prev occurrence
C-LeftMouse
Add cursor at mouse
C-RightMouse
Add cursor on word at mouse
A-C-RightMouse
Add column mouse selection
y s <motion>
Add surround (e.g. ysiw")
c s <old> <new>
Change surround (e.g. cs"')
d s <char>
Delete surround (e.g. ds()
S <char>V
Surround visual selection

LSP & Formatting

K
Hover documentation
g d
Go to definition
g r r
Find references (Quickfix)
g r i
Find implementations
g O
Document outline
F2
Rename symbol
␣ c aV
Code action
␣ fA-S-f V
Smart Format / Rewrap prose
g q
Format paragraph / selection
C-SpaceI
Trigger autocomplete (Nvim-Cmp)

Diagnostics

] d[ d
Next / prev diagnostic
] D[ D
Last / first diagnostic in buffer
] e[ e
Next / prev error
] w[ w
Next / prev warning
␣ d f
Show diagnostic float for line
␣ d b␣ p d
Buffer diagnostics (Snacks)
␣ d w␣ p a
Diagnostics across buffers (Snacks)
␣ d e␣ p e
Buffer errors (Snacks)
␣ d l
Toggle diagnostic virtual lines
␣ d t
Toggle diagnostics
␣ c aV
Code action

Jumplist, Quickfix & History

C-oC-i
Jump older / newer (Jumplist)
g ;g ,
Jump older / newer (Changelist)
␣ q
Toggle Quickfix list
] q[ q
Next / prev Quickfix entry
:Rg <query>
Ripgrep to Quickfix
:cdo s/a/b/ge | update
Batch replace across Quickfix
[ m] m
Prev / next method start
[ {] }
Prev / next enclosing { }
*#
Search word forward / backward
␣ /V
Search selected text

Snacks Picker & Search

␣ p fC-p
Find Files
␣ p sC-A-f
Live Grep in files
␣ p bF5
Find Buffers
␣ p wC-g
Recent buffers in window
␣ p p
Find Projects
␣ p r
Recent Files
␣ p l
Find Lines in buffer
␣ p j
Find Jumps
␣ p c
Select Colorschemes
␣ p kF11
Show active keymaps
␣ p g␣ g s
Git status
␣ p d␣ d b
Buffer diagnostics
␣ p a␣ d w
Diagnostics across buffers
␣ p e␣ d e
Buffer errors
␣ ?
Buffer-local keymaps (Which-Key)

Explorer & OS Tools

C-A-e
Toggle Explorer (Snacks)
A-S-rIV
Reveal file in OS manager
\ g␣ g g
LazyGit popup
␣ g s
Git Status picker
␣ `C-F12
Toggle Terminal
␣ c d
Set current file directory (lcd)

Buffers & Splits

C-tF12
New empty buffer (:enew)
A-LeftA-Right
Previous / next buffer in window (WinBuf)
␣ p wC-g
Recent buffers in window
C-S-PgUpC-S-PgDnC-w wC-w W
Previous / next window
A-hA-jA-kA-l
Move buffer to adjacent split (WinBuf)
C-F4␣ x
Close buffer (Snacks.bufdelete)
C-6C-^
Toggle alternate (last) buffer
␣ -
New horizontal split (:new)
␣ |
New vertical split (:vnew)
C-w -
Rotate split to horizontal
C-w |C-w \
Rotate split to vertical