normal·mode

neovim notes

The drills run in a browser Vim emulator that's set up to behave like Neovim's defaults. For example, Y yanks to the end of the line, and patterns use Vim regex syntax. This page gathers every place where Neovim differs from classic Vim or adds something on top, so you know what to expect when you open nvim for real.

drill the neovim extras →

neovim-specific keys

Yyank to the end of the line (y$)Line shortcuts: dd, cc, D, C, J and friends
{Visual}*search for the selected textRename one at a time: *, n and cgn
{Visual}@alinewise Visual: run register a on each selected lineRun a macro on many lines: :normal @a
"aYyank to the end of the line into register aEdit a macro as text
Yyank from the cursor to the end of the line (y$)What Neovim changes: Y and saner defaults
{count}<C-a>add count to the number at or after the cursor (007 is decimal)What Neovim changes: Y and saner defaults
{count}<C-x>subtract count from the number at or after the cursorWhat Neovim changes: Y and saner defaults
<C-l>redraw and clear search highlightingWhat Neovim changes: Y and saner defaults
[<Space>add [count] empty lines above the cursor lineRoom to breathe: [<Space> and ]<Space>
]<Space>add [count] empty lines below the cursor lineRoom to breathe: [<Space> and ]<Space>
gcctoggle comments on [count] linesComment lines: gcc and gc{motion}
gc{motion}toggle comments on the lines {motion} coversComment lines: gcc and gc{motion}
{Visual}gctoggle comments on the selected linesComment lines: gcc and gc{motion}
gcgcuncomment the comment block around the cursorComment blocks: gcgc, dgc and ygc
dgcdelete the comment block around the cursorComment blocks: gcgc, dgc and ygc
ygcyank the comment block around the cursorComment blocks: gcgc, dgc and ygc
{Visual}gctoggle comments on the selected linesComment blocks: gcgc, dgc and ygc
{Visual}*search forward for the selected textSearch for the selection: Visual * and #
{Visual}#search backward for the selected textSearch for the selection: Visual * and #
&repeat the last :s on this line, keeping its flags (:&&)&: repeat the last substitution
{count}&repeat it on count lines from the cursor&: repeat the last substitution
Qreplay the last recorded register [count] timesQ: replay the last recording
{Visual}Qlinewise Visual: replay it once on each selected lineQ: replay the last recording
{Visual}@{reg}linewise Visual: run register {reg} on each selected lineQ: replay the last recording
Moving Around

The whole file: gg, G, {n}G and :{n}

Neovim turns 'startofline' off by default, so gg, G, {count}G and :{count} keep the cursor in the same column (when the line is long enough). Classic Vim moves you to the first non-blank character instead. The same goes for H, M, L and the scrolling keys. To get the Vim behaviour back, :set startofline.

Moving Around

The screen: H M L, scrolling and zz

Because Neovim leaves 'startofline' off, H, M, L and the CTRL-D/CTRL-U/CTRL-F/CTRL-B scrolls keep your column instead of jumping to the first non-blank. Neovim also turns the mouse on by default, and the scroll wheel scrolls the window rather than moving the cursor.

Insert Mode

Fix it without leaving: <C-h>, <C-w>, <C-u>

Out of the box Neovim maps <C-w> to <C-g>u<C-w> and <C-u> to <C-g>u<C-u> (see :h default-mappings). The <C-g>u starts a new undo step first, so if one of them deletes too much, u after <Esc> brings the text back while keeping what you typed before it.

Insert Mode

Paste while typing: <C-r>{register}

Neovim inserts named and numbered registers (a–z, 0–9, +) literally, like pasting with p. Classic Vim "types" them in, so options such as autoindent and textwidth can reshape multi-line text on the way.

Insert Mode

Do the maths in place: <C-r>=

Neovim colours the = prompt with its own expression parser while you type (:h expr-highlight), so mistakes like a missing bracket stand out before you press <CR>.

Operators & the Dot

Line shortcuts: dd, cc, D, C, J and friends

Neovim maps Y to y$, so it yanks to the end of the line just like D and C. In classic Vim, Y yanks the whole line (the same as yy).

Neovim also turns 'autoindent' on by default, which is why cc and S keep the line's indent. Classic Vim's default is off, so there they start at column 0.

Operators & the Dot

Rename one at a time: *, n and cgn

Neovim adds a default mapping for * and # in Visual mode: select some text (it doesn't have to be a whole word) and press * to search for exactly that.

Operators & the Dot

Counts: do it N times

Neovim's 'nrformats' defaults to "bin,hex", so a number with leading zeros is decimal and keeps its width: <C-a> on 007 gives 008. Vim's built-in default also includes "octal" (its defaults.vim removes it), which would turn 007 into 010.

Find & Jump

Matching pairs: %, [( and [{

Neovim loads the matchit plugin by default. In file types that set it up (HTML, Lua, Vim script, shell and more), % also cycles through matching keywords and tags, like if/else/end or <div>/</div>. With syntax highlighting on, it also skips brackets inside comments and strings. This trainer only matches brackets.

Find & Jump

Marks: m, ` and '

Neovim saves your uppercase file marks in its ShaDa file (its replacement for Vim's viminfo), so 'A still takes you back to that file after you restart.

Find & Jump

The jump list: CTRL-O and CTRL-I

Neovim adds the 'jumpoptions' option. :set jumpoptions+=stack makes the list behave like browser history: jump somewhere new from the middle of the list and the newer entries are dropped. view also restores the scroll position when you jump back. And in terminals that support it, CTRL-I and <Tab> can be mapped separately.

Find & Jump

The change list: g; and g,

With :set jumpoptions+=view, Neovim also restores the scroll position when g; and g, take you back to a change (the same goes for the jump list and marks).

Text Objects

Mix and match: any operator, any object

Neovim has one more object: gc in Operator-pending mode is the block of commented lines around the cursor, so dgc deletes a whole comment block and gcgc uncomments it.

Neovim 0.12 also adds Visual-mode an and in, which select by syntax node using Treesitter (or the language server when there is no parser): an selects the parent node and in a child node, so repeating an grows the selection one meaningful chunk at a time. They need a parser, so this practice editor does not have them.

Visual Mode

v, V and Ctrl-v: select, then act

Neovim adds a few Visual-mode defaults on top of Vim's: * and # search for the selected text (see the Neovim module), and @{reg} on a linewise selection runs a macro once per selected line (see Macros).

Visual Mode

Repeat a Visual edit with .

Neovim 0.12, the current release, repeats Visual edits by size, exactly as described here (and as this editor does). The development version changes that: . replays the selection keys themselves, so viwU followed by . would uppercase the next word whatever its length. Until that ships in a release, count on the size rule.

Visual Mode

Operators repeat better than selections

In Neovim 0.12 a Visual repeat works by size, as described here. Neovim's development version replays the selection keys instead, which makes vi"U + . adapt like an operator would. Operators + text objects behave the same in every version, so they're the habit worth building.

Registers

The unnamed register: x, dd, yy and p

In Neovim Y yanks to the end of the line, like D and C, instead of the whole line. Use yy for whole lines: Yp would put the rest of the line inline, not a new line.

Registers

Named registers: "a to "z

Neovim's system clipboard is the "+ register: "+y copies to it and "+p pastes from it. Neovim talks to the clipboard through a tool such as pbcopy on macOS. To make every yank and put use it, add set clipboard+=unnamedplus to your config.

Registers

Replace a selection with p (and P)

Visual P keeping your registers untouched is how Neovim (and Vim 9) behave. Older Vim treated P and p the same in Visual mode, so older tutorials may tell you to use "0p for this instead. That still works too.

Registers

More ways to put: gp, ]p, counts and Ctrl-r

In Neovim, <C-r> with a letter or number register inserts the text literally, the way p would. Vim inserts it as if you had typed it, so options like autoindent can reshape it on the way in.

Macros

Run a macro on many lines: :normal @a

Neovim has a default mapping for this: in linewise Visual mode (V), @a runs register a on every selected line, just like :'<,'>normal @a. See :h v_@-default.

Macros

Counting with CTRL-A

Neovim's 'nrformats' default is bin,hex, so a number with leading zeros is still decimal: <C-a> on 07 gives 08, keeping the zero padding.

Macros

Edit a macro as text

In Neovim Y yanks to the end of the line (like y$), so 0"aY puts the line in register a without its line break, one key shorter than 0"ay$.

Search & Patterns

Search: / ? n and N

Neovim turns on 'hlsearch' and 'incsearch' by default, so every match lights up and the cursor previews the first match while you type. It also shows a match count like [2/5] after each search: Vim hides that unless you remove S from 'shortmess', Neovim leaves S out. Run :nohlsearch (:noh) or press <C-l> to clear the highlighting until your next search.

Search & Patterns

Whole words: * # g* and \< \>

Neovim adds * and # in Visual mode by default (:h v_star-default): select some text, press *, and it searches forward for exactly that text, dots, slashes and spaces included (# searches backward). Plain Vim has no such mapping. The Neovim module has drills for it.

Search & Patterns

Case: ignorecase, smartcase, \c and \C

Both options are off in a fresh Neovim. To get this editor's behaviour, add vim.o.ignorecase = true and vim.o.smartcase = true to your init.lua. 'smartcase' only applies to patterns you type: * and # use 'ignorecase' but ignore 'smartcase'.

Search & Patterns

Very magic \v, very nomagic \V

Neovim (like Vim) can open the search history in a small window with q/, where you edit an old pattern with normal Vim keys and press <CR> to run it. That window isn't available in this editor; <Up> and <Down> in the prompt are.

Search & Patterns

gn: edit match after match

Neovim shows the match count, like [3/7], every time you search or press n (it leaves S out of 'shortmess'), so for a quick count you can often skip :s///gn.

Ex Commands

Substitute: :s, ranges and flags

Neovim previews a substitution live in the buffer while you type it (the 'inccommand' option, nosplit by default). This editor only highlights the matches.

Ex Commands

Grab the word under the cursor: <C-r><C-w>

Neovim turns 'incsearch' on by default, and with it <C-r><C-w> skips the part of the word you already typed: on counter, typing :s/cou then <C-r><C-w> adds only nter.

Windows & Tabs

Split the screen: <C-w>s, <C-w>v, :sp, :vs

Neovim shows a status line on every window by default ('laststatus' is 2), so you can always see which buffer each window holds. It also has :set laststatus=3, which swaps them for one global status line at the bottom.

New splits open above or on the left. If you prefer below and right, put vim.opt.splitbelow = true and vim.opt.splitright = true in your init.lua.

Windows & Tabs

Move between windows: <C-w>h j k l, w, p

Neovim adds floating windows, which LSP hovers and many plugins use. A float that is marked non-focusable gets no window number, so <C-w>w, <C-w>W and {N}<C-w>w skip it: cycling only visits windows you can actually work in.

Windows & Tabs

Close windows: <C-w>c, <C-w>o

Neovim turns on 'hidden' by default. When the last window on a buffer with unsaved changes closes, the buffer is simply hidden (your changes stay), so :close and :only never stop to ask. In Vim without 'hidden', :only leaves windows with unsaved changes open unless you add !.

Neovim Extras

What Neovim changes: Y and saner defaults

Y is a default mapping to y$ (:h Y-default); :unmap Y gives you Vim's version back. 'nrformats' defaults to "bin,hex" (:h 'nrformats'). The full list lives in :h vim-differences.

Neovim Extras

Comment lines: gcc and gc{motion}

Built-in commenting arrived in Neovim 0.10 (:h commenting). With a treesitter parser installed, code embedded in another language (say, Lua inside Markdown) gets the marker for its own language.

Neovim Extras

Comment blocks: gcgc, dgc and ygc

The gc text object is a Neovim default too (:h o_gc), and it only exists after an operator: in Normal and Visual mode gc is the comment toggle.

Neovim Extras

&: repeat the last substitution

In Vim, & is the same as :s, which forgets the flags, so the g would be lost. Neovim maps & to :&&<CR> (:h &-default).

Neovim Extras

Q: replay the last recording

In Vim, Q switches to Ex mode; Neovim moved that to gQ (:h vim-differences). Visual Q and @ running per line arrived in Neovim 0.10 (:h v_Q-default).

outside the editor the page is in normal mode: ? keymaps · / find · : commandsfound this useful? ☕ support it ·credits · source · not affiliated with Vim or Neovim