← Back to overview

Useful Built-in Commands Worth Knowing

Quickfix and Location Lists

:vimgrep /pattern/ **/*     " Search across files, populate quickfix
:copen                       " Open quickfix window
:cnext / :cprev              " Navigate quickfix entries

Macros

Macros record a sequence of keystrokes and replay them:

  1. q{register} — Start recording (e.g., qa to record into register a)
  2. Perform your edits
  3. q — Stop recording
  4. @{register} — Replay (e.g., @a)
  5. @@ — Replay last macro

Registers

Neovim has named registers for storing text:

RegisterContent
""Default (last delete/yank)
"0Last yank
"1-"9Last 9 deletes
"a-"zNamed registers (user-defined)
"+System clipboard
"*Selection clipboard
".Last inserted text
"%Current file name
":Last Ex command

To paste from a specific register: "ap (paste from register a).

Marks

Marks save cursor positions:

MarkDescription
maSet mark a at current position
`aJump to exact position of mark a
'aJump to line of mark a
''Jump to position before last jump
'.Jump to position of last change

Uppercase marks (mA) are global (work across files).

Other Useful Commands

CommandDescription
gaShow ASCII/Unicode value of character under cursor
g Ctrl-gWord count and position info
Ctrl-aIncrement number under cursor
Ctrl-xDecrement number under cursor
:!{cmd}Run external shell command
!!{cmd}Filter current line through command
:{range}!{cmd}Filter range through command
:r !{cmd}Insert output of command below cursor
:r {file}Insert contents of file below cursor
gq{motion}Format (wrap) text
Ctrl-oJump to older position (in Insert mode too)
Ctrl-iJump to newer position

Quick Reference Card

╔══════════════════════════════════════════════════════════════╗
║                    NEOVIM QUICK REFERENCE                    ║
╠══════════════════════════════════════════════════════════════╣
║ NAVIGATION        │ EDITING           │ FILES               ║
║ h j k l           │ i a o O           │ :w :q :wq           ║
║ w b e             │ dd yy             │ :e {file}           ║
║ 0 ^ $             │ p P               │ :bn :bp             ║
║ gg G              │ u Ctrl-r          │ :bd                 ║
║ Ctrl-u Ctrl-d     │ x X               │                     ║
║ /pattern n N      │ c m. t            │                     ║
║                   │ .                 │                     ║
╠═══════════════════╪═══════════════════╪═════════════════════╣
║ TEXT OBJECTS      │ WINDOWS           │ SEARCH/REPLACE      ║
║ iw aw             │ Ctrl-w s v        │ :%s/old/new/g       ║
║ i" a"             │ Ctrl-w h j k l    │ :%s/old/new/gc      ║
║ i( i)             │ Ctrl-w o          │                     ║
║ i{ i}             │ Ctrl-w =          │                     ║
║ it at             │                   │                     ║
║ ip ap             │                   │                     ║
╠═══════════════════╪═══════════════════╪═════════════════════╣
║ VISUAL MODE       │ TERMINAL          │ MARKS & REGISTERS   ║
║ v V Ctrl-v        │ :term             │ ma 'a               ║
║ d y c > <         │ Ctrl-\ Ctrl-N     │ "ayy "ap            ║
║ J K (move lines)  │                   │ "+y  "+p            ║
╚═══════════════════╧═══════════════════╧═════════════════════╝