Neovim Cheatsheet
File Navigation
:e filename— open file:Ex— open file explorer:w— save:q— quit
Scrolling
zz— scroll so current line is centeredzb— scroll so current line is at bottomzt— scroll so current line is at top
Navigation
fx/Fx— move to next/previous occurrence ofxtx/Tx— move right before next/previous occurrence ofx;/,— repeat/unrepeat lastf,F,t, orTmotion
Mode Switching
<C-o>— switch to command mode temporarily for one command
Text Casing
~— invert case of the character under the cursorg~+ range (e.g.g~e,g~$,g~iw,g~0) — invert case over a rangegu+ range — lowercase over a rangegU+ range — UPPERCASE over a range
Folding
zM— close all foldszm— fold more (increase folding level)zR— open all foldszr— unfold one levelzO— open fold recursively under cursorzo— open current fold
Multicursor Editing (Visual Block)
<C-v>— enter Visual Block mode- Use
j/kto select multiple lines $— move to end of each lineA— append text at the end- Type your text
<Esc>— finish block insert
Replacing
: %s/old_text/new_text/gReplace all occurrences in the current file
Surround (via nvim-surround)
ys{motion}{char}— add surroundingds{char}— delete surroundingcs{target}{replacement}— change surrounding
Examples
| Old Text | Command | New Text |
|---|---|---|
surr*ound_words | ysiw) | (surround_words) |
*make strings | ys$" | "make strings" |
[delete ar*ound me!] | ds] | delete around me! |
remove <b>HTML t*ags</b> | dst | remove HTML tags |
'change quot*es' | cs'" | "change quotes" |
<b>or tag* types</b> | csth1<CR> | <h1>or tag types</h1> |
delete(functi*on calls) | dsf | function calls |
✅ Tip: Install
nvim-surroundwith a plugin manager likelazy.nvim,packer.nvim, orvim-plugto use the surround shortcuts.