Skip to content
kamack38 edited this page Mar 10, 2026 · 46 revisions

Neovim Cheatsheet

  • :w ++p - save a file and create all necessary directories
  • :f ./newfile - copy currently opened file and give it a new name
  • :e %:h/file - edit a file relative to the currently opened buffer parent directory
  • :cq - quits Neovim with 1 error code (useful for aborting git commits)
  • :reg - show contents of the registers
  • :%! - filter the entire buffer through an external command
  • gv - reselects the last selection
  • ga - information about a character under cursor
  • gU{motion} - convert to uppercase
  • gu{motion} - convert to lowercase
  • <C-a> - increment number
  • <C-x> - decrement number
  • <C-g> - print full file path
  • o - jump between the start and the end of a visual selection
  • q{A-Z} - append to a macro
  • * - searches forward for the word nearest to the cursor

Marks (via me)

  • mx - toggle mark 'x' and display it in the leftmost column
  • dmx - remove mark 'x'
  • dm; - delete all marks on the current line
  • dm<Space> - delete all marks in the current buffer
  • m] - jump to next mark
  • m[ - jump to previous mark

Surround (via nvim-surround)

  • ys{motion}{char} - surrounds a {motion} with a {char}
  • ds{char} - delete a {char} surround
  • cs{char1}{char2} - changes a {char1} surround to {char2}

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

Motions

  • gj - go one visual line down
  • gk - go one visual line up
  • gm - go to the middle of the screen

Line motions

  • D delete till the end of line
  • C change till the end of line
  • Y yank till the end of line
  • S replace the whole line

Objects

  • w - a word
  • W - a WORD
  • s - a sentence
  • p - a paragraph
  • t - a <tag>
  • []/<> - a []/<> block
  • ()/b - a () block
  • {}/B - a {} block

Modifiers

  • i - inner
  • a - "a" (around)

All text objects

Additional text objects (via nvim-various-textobjs)

textobject description inner / outer keymaps
indentation lines with same or higher indentation ii, ai, aI, (iI)
restOfIndentation lines down with same or higher indentation - R
greedyOuterIndentation outer indentation, expanded to blank lines; useful to get functions with annotations o: a blank, like ap/ip ag/ig
subword segment of a camelCase, snake_case, and kebab-case words. o: trailing/leading _,- iS/aS
toNextClosingBracket from cursor to next closing ], ), or } - C
toNextQuotationMark from cursor to next unescaped ", ', or ` - Q
anyQuote between any unescaped ", ', or ` in a line o: quotation marks iq/aq
anyBracket between any (), [], or {} in a line o: brackets io/ao
restOfParagraph like }, but linewise - r
entireBuffer entire buffer as one text object - gG
nearEoL from cursor position to end of line, minus one character - n
lineCharacterwise current line, but characterwise o: indentation and trailing spaces i_/a_
column column down until indent or shorter line. Accepts {count} for multiple columns. - |
value value of key-value pair, or right side of a assignment, excl. trailing comment (in a line) o: trailing commas or semicolons iv/av
key key of key-value pair, or left side of a assignment o: includes the = or : ik/ak
url works with http[s] or any other protocol - L
number numbers, similar to <C-a> i: digits, o: including -, , and . in/an
diagnostic LSP diagnostic (requires built-in LSP) - !
closedFold closed fold o: one line after the last folded line iz/az
chainMember field with optional call, like .foo(param) or .bar o: leading . (or :) im/am
visibleInWindow all lines visible in the current window - gw
restOfWindow from the cursorline to the last line in the window - gW
lastChange Last non-deletion-change, yank, or paste.[^2] - g;
notebookCell cell delimited by double percent comment, such as # %% o: includes the bottom cell border iN/aN
emoji single emoji (or Nerdfont glyph) - .
argument comma-separated argument o: includes the , i,/a,
filepath UNIX-filepath; supports ~ or $HOME, but not spaces in the filepath. i: only the filename iF/aF
color HEX; RGB or HSL in CSS format; ANSI color code. i: only color value i#/a#

Jumping

  • ( and ) - moves between sentences
  • { and } - moves between paragraphs
  • [ and ] - jumps between objects
  • % - jumps between matching braces
  • <C-]>, K - jump to a tag
  • <C-o> - move backwards through the jump list
  • <C-i> - move forward through the jump list
  • [[ and ]] - jumps between shell prompts in :terminal
  • H - jump to the top of the view
  • L - jump to the bottom of the view
  • g. - jump to the next change
  • g; - jump to the last change
  • gi - insert at the last insert position

Splits

  • <C-hjkl> - move between splits

  • <C-W> HJKL - move split

  • <C-W> = - make all splits equally high and wide

  • <C-W>[count]_ - set window height

  • <C-W>[count]+ - increase window height

  • <C-W>[count]- - decrease window height

  • <C-W>[count]| - set window width

  • <C-W>[count]> - increase window width

  • <C-W>[count]< - decrease window width

  • :vert[ical] {cmd} - Execute {cmd}. If it contains a command that splits a window, it will be split vertically. (Useful for vertical help)

See more All window commands

Tabs

  • :tabnew - create a new tab page with an empty window
  • gt - go to the next tab page.
  • gT - go to the previous tab page.

See more

Sessions

  • :mksession [file] - creates a session file
  • :source [file] - reads a session file
  • -S [file] - loads a session (cmdline option)
  • :wshada! [file] - writes to shada file
  • :rshada! [file] - reads from shada file
  • :mkview [file] - creates a view
  • :loadview [file] - loads a view

Regex

  • :g/pattern/d - remove lines matching pattern
  • :g!/pattern/d - remove lines that do NOT match
  • .\{-} - not greedy version of .*
  • & - inserts the matched text in a replacement pattern

Command-line

  • <C-b> - cursor to begin of command-line
  • <C-e> - cursor to end of command-line
  • <C-r>{register} - insert the contents of a numbered or named register
  • :!{cmd} - execute {cmd}
  • :r!{cmd} - execute {cmd} and insert its standard output below the cursor
  • '<,'>w !{cmd} - pass selection to {cmd} and print its output in viminfo
  • q: - open command history (in normal mode). Hit <CR> to execute.

Ranges

  • :* - uses last visual area after visual mode has already ended

Repeats

  • . - repeats last change
  • ; - repeats latest f, t, F or T
  • , - repeats latest f, t, F or T in opposite direction
  • @: - repeats last command-line

See more

Insert mode

  • <C-u> - delete till the start of the line
  • <C-o> - go to normal mode only for the next command

Git (using gitsigns.nvim)

  • :Gitsigns stage_hunk - toggle stage the current hunk (works with visual selection)

Tips

  • v<text-object><Esc> - to go to the text object
  • :verbose set <value>? - get which file changes a variable
  • :'<,'>t'a - to copy last selection under mark a
  • :'<,'>norm A; - run normal mode command on each line
  • :s/someWord/\r/ - replace someWord with new line
  • :doautocmd <group> <event> - run an autocmd group
  • :put x - to paste the contents of register x to current buffer
  • [/]<Space> - insert a new line above / below the cursour

All Neovim mappings Signing Git commits in NeoVim Vim Cheat Sheet

For differences between NeoVim and Vim, see :h vim_diff

Clone this wiki locally