Neovim / Vim keyboard shortcuts

Neovim's default key mappings and commands, checked against the help files of release 0.12.5; one keymap serves every system. The first groups hold Neovim's additions to Vim: LSP keys such as grn, diagnostics, commenting with gcc, the terminal, Lua commands, :checkhealth and startup options. Typed commands are case-sensitive, and chords are written like Ctrl + W, D (CTRL-W, then d). The option list, Vimscript and the long tail of Normal-mode commands are left to the Vim pages.

447 shortcuts in 29 sections. Checked row by row against Neovim help: vim_diff.txt, Differences between Nvim and Vim (Neovim 0.12.5, tag v0.12.5) on . Edited by Jay.

Default mappings Neovim adds 17

ActionShortcut
Yank to end of lineNeovim maps this key to y$; in Vim it is a synonym for yy and copies the whole line.Y
Replay last recorded macroRuns the register recorded most recently; Vim uses this key to switch to Ex mode instead.Q
Replay macro on each selected lineWorks from a linewise Visual selection and runs the last recording once per line.Q
Run a register on each selected lineTyped in linewise Visual mode with a register name after the @ sign.@{0-9a-z".=*+}
Repeat substitute with its flagsThe default mapping runs :&& so the flags of the previous :s are reused.&
Redraw and clear search highlightBesides repainting the screen, the default mapping runs :nohlsearch and refreshes diffs.Ctrl+L
Search forward for the selectionIn Visual mode the highlighted text becomes the search pattern instead of the word at the cursor.*
Search backward for the selectionThe Visual-mode counterpart of the star mapping, going toward the top of the file.#
Delete typed text with undo pointIn Insert mode Neovim first starts a new undo step, so u can bring the removed text back.Ctrl+U
Delete word with undo pointInsert mode: the word in front of the cursor goes, and the deletion can be undone on its own.Ctrl+W
Add blank line belowStays in Normal mode; a count adds that many empty lines.]thenSpace
Add blank line aboveThe cursor line moves down and Normal mode is kept.[thenSpace
Open path or URL at cursorHands the file path, URL or LSP document link to the operating system's default application.gx
Open selected text externallyIn Visual mode the highlighted text is passed to the system handler.gx
Show buffer outlineA table of contents for help pages and man pages; with a language server attached it lists the document symbols.gO
Run code block in helpExecutes the example the cursor is in; only help buffers support it.g==
Restart NeovimRuns :restart; with a count from 1 to 8 the session is not restored afterwards.ZR

LSP and diagnostics 34

The gr mappings, gO and Ctrl-S are created when Neovim starts, whether or not a language server is running; K, Ctrl-], gq and omni completion use the server only in buffers where a client is attached.

The LSP mappings that begin with gr can get in the way of the built-in gr{char} (virtual replace) command; the help gives a nnoremap line with the nowait flag that restores it.

ActionShortcut
Rename symbolAsks the language server to rename every reference to the symbol at the cursor.grn
Code actionOffers the fixes and refactorings the server has for the cursor position or the Visual selection.gra
List referencesPuts every reference to the symbol at the cursor in the quickfix window.grr
List implementationsShows each implementation of the symbol at the cursor in the quickfix window.gri
Go to type definitionJumps to where the type of the symbol at the cursor is declared; a default since 0.12.grt
Run code lensExecutes the code lens at the cursor position; this default arrived in release 0.12.grx
Show hover informationOpens a floating window with the server's documentation; pressing K twice moves the cursor into it.K
Show signature helpInsert mode only: displays the parameters of the function call being typed.Ctrl+S
Go to definitionThe tag jump asks the language server because Neovim sets 'tagfunc' when a client attaches.Ctrl+]
Go to definition in a splitThe window is split first, then the server-backed tag jump runs in the new one.Ctrl+Wthen]
Preview definitionShows the definition in the preview window and leaves the cursor where it was.Ctrl+Wthen}
Complete from language serverOmni completion in Insert mode; 'omnifunc' points at the LSP client in attached buffers.Ctrl+XthenCtrl+O
Format with language serverFollowed by a motion; uses the server because 'formatexpr' is set when it supports formatting.gq
Format without language serverReflows text with the built-in formatter and ignores 'formatexpr'.gw
Next diagnosticMoves to the following error, warning or hint in the buffer.]d
Previous diagnosticMoves back to the diagnostic before the cursor in the same buffer.[d
Last diagnostic in buffer]D
First diagnostic in buffer[D
Show diagnostic in a floatOpens a floating window with the full message for the problem at the cursor.Ctrl+WthenD
Enable a language server configTurns LSP on for buffers that are open now and for ones opened later.:lsp enable [config_name]
Disable a language server configAlso stops the server when it is running.:lsp disable [config_name]
Restart language serversWith no name, restarts every client attached to the current buffer.:lsp restart [client_name]
Stop language serversWith no name, stops every client attached to the current buffer.:lsp stop [client_name]
Check LSP statusReports which configs are enabled and which buffers have a client attached.:checkhealth vim.lsp
Print server capabilitiesRun it in an LSP-enabled buffer to see what the first attached server supports.:lua =vim.lsp.get_clients()[1].server_capabilities
See what set omnifuncA first check when LSP completion does not work: the value should name vim.lsp.omnifunc.:verbose set omnifunc?
Define a language server configLua function for init.lua; defines or changes the settings stored under a config name.vim.lsp.config()
Auto-start a language serverLua function; once called, the named config starts for buffers of its filetypes.vim.lsp.enable()
Format buffer through LSPLua function; call it with :lua or from a BufWritePre autocommand to format on save.vim.lsp.buf.format()
Turn inlay hints on or offLua function; inlay hints are off until it is called.vim.lsp.inlay_hint.enable()
Enable inline completionLua function new in 0.12 for servers that send whole-line suggestions.vim.lsp.inline_completion.enable()
Send diagnostics to quickfix listLua function; the whole set of diagnostics becomes one list to step through.vim.diagnostic.setqflist()
Send diagnostics to location listLua function; covers the current buffer only.vim.diagnostic.setloclist()
Configure diagnostic displayLua function that sets how diagnostics are shown, such as virtual text, virtual lines and signs.vim.diagnostic.config()

Stepping through lists 26

ActionShortcut
Next quickfix itemA default mapping that simply runs the :cnext command.]q
Previous quickfix itemSteps backwards through the list by running :cprevious.[q
Last quickfix itemJumps straight to the final entry by running :clast.]Q
First quickfix itemRuns :crewind, which shows the first entry again.[Q
Quickfix: next fileSkips the remaining entries of this file and shows the first one in the following file.]thenCtrl+Q
Quickfix: previous fileShows the last entry of the file that precedes the current one in the list.[thenCtrl+Q
Next location-list itemThe location list belongs to the current window; the mapping runs :lnext.]l
Previous location-list item[l
Last location-list item]L
First location-list item[L
Location list: next file]thenCtrl+L
Location list: previous file[thenCtrl+L
Next bufferCycles through the buffer list by running :bnext.]b
Previous bufferRuns :bprevious, the reverse of the ]b mapping.[b
Last buffer]B
First buffer[B
Next file in argument listThe argument list holds the files named when Neovim was started; this runs :next.]a
Previous file in argument list[a
Last file in argument list]A
First file in argument list[A
Next matching tagUseful after a tag jump that had several matches; runs :tnext.]t
Previous matching tag[t
Last matching tag]T
First matching tag[T
Next tag in preview windowRuns :ptnext, so the match is shown in the preview window.]thenCtrl+T
Previous tag in preview window[thenCtrl+T

Commenting 5

ActionShortcut
Toggle comment on lineA count toggles that many lines, starting at the cursor line.gcc
Toggle comment over a motionAn operator: gcip toggles a paragraph, for example. The markers come from 'commentstring'.gc{motion}
Toggle comment on selectionIn Visual mode every selected line is commented, or uncommented when all of them already are.gc
Uncomment a comment blockThe second gc is a text object for the block of commented lines around the cursor.gcgc
Delete a comment blockUses the gc text object after the delete operator; it exists only in Operator-pending mode.dgc

Treesitter selection and inspection 14

ActionShortcut
Select parent nodeIn Visual mode, widens the selection to the enclosing syntax node; falls back to LSP selection ranges without a parser.an
Select child nodeIn Visual mode, shrinks the selection again to the node inside it.in
Select next nodeVisual mode: the selection moves to the node after the current one.]n
Select previous node[n
Extend selection to next nodeKeeps what is selected and adds the following sibling node.]N
Extend selection to previous node[N
Open the syntax tree windowDisplays the nodes of the language tree as text in a separate window.:InspectTree
Toggle anonymous nodesWorks only inside the :InspectTree window.a
Toggle query editorIn the :InspectTree window, opens or closes the live query editor beside the tree.o
Jump to node in sourceIn the :InspectTree window, moves to the text of the node on the cursor line.Enter
Open live query editorText matched by a capture is highlighted in the source buffer while the query is edited.:EditQuery
Show highlights at cursorLists the treesitter captures, semantic tokens, syntax groups and extmarks at the cursor position.:Inspect
Start treesitter highlightingLua function, meant for an ftplugin or a FileType autocommand.vim.treesitter.start()
Run the treesitter health check:checkhealth vim.treesitter

Terminal 12

ActionShortcut
Open a terminal bufferStarts an interactive shell in the current window when no command is given.:terminal
Run a command in a terminalThe buffer shows the output of that one program rather than an interactive shell.:terminal {cmd}
Open terminal in a splitThe :horizontal modifier keeps the current buffer visible above the shell.:hor te
Open terminal in a vertical split:vert te
Open a terminal by buffer nameEditing a term:// name starts that program; :vsplit term://top works the same way.:edit term://bash
Enter Terminal modeFrom Normal mode in a terminal buffer; after it, keys go to the program running there.i
Enter Terminal mode by commandHandy in mappings and autocommands that open a terminal.:startinsert
Leave Terminal modeReturns to Normal mode so the terminal output can be scrolled, searched and yanked.Ctrl+\thenCtrl+N
Run one Normal-mode commandTerminal mode resumes by itself after the single command.Ctrl+\thenCtrl+O
Map Esc to leave Terminal modeThe mapping the manual suggests; :tnoremap creates mappings that apply in Terminal mode only.:tnoremap <Esc> <C-\><C-n>
Next shell promptIn a terminal buffer, when the shell marks its prompts with OSC 133 sequences.]]
Previous shell promptJumps back one prompt in the scrollback under the same OSC 133 condition.[[

Lua and configuration commands 23

ActionShortcut
Run Lua codeEach :lua command has its own scope, so a local variable is gone by the next command.:lua {chunk}
Evaluate and print a Lua expressionTables are printed in readable form, the way vim.inspect shows them.:lua =expr
Print Lua expression, short formDoes the same as :lua =expr with less typing.:=expr
Run selected lines as LuaSelect code in Visual mode and type :lua; unlike :source it never interprets the lines as Vimscript.:{range}lua
Run a Lua fileEverything after the command is the file name, so spaces need no escaping.:luafile {file}
Run a Vimscript or Lua fileFiles ending in .lua are executed as Lua, everything else as Ex commands.:source {file}
Source the current bufferWith no file name the buffer itself is run, as Lua when its filetype is lua; a range limits it to those lines.:source
Source a file from runtimepathSearches each 'runtimepath' directory for the relative path and runs the first match; ! runs all matches.:runtime {file}
Show the config directoryinit.lua or init.vim belongs in this directory; Neovim accepts one of the two, not both.:echo stdpath('config')
Create a key mapping in LuaTakes the mode, the keys to press and a command string or Lua function to run.vim.keymap.set()
Remove a key mapping in LuaThe way to drop a default such as grn from init.lua.vim.keymap.del()
Run an Ex command from LuaAlso callable by command name, as in vim.cmd.colorscheme("habamax").vim.cmd()
Set options from LuaThe Lua counterpart of :set; vim.opt_local and vim.opt_global mirror :setlocal and :setglobal.vim.opt
Create an autocommand in LuaCalled as vim.api.nvim_create_autocmd with the events and a table holding the pattern and callback.nvim_create_autocmd()
Create a user command in LuaCalled through vim.api; the command name has to begin with a capital letter.nvim_create_user_command()
Remove one default mappingA config line that gives Y its Vim meaning back; any other default mapping is removed the same way.:unmap Y
Remove all default mappingsRun it early in the config when none of the default mappings are wanted.:mapclear
Restore Vim's default colorsBrings back the highlight links and colors from before Neovim changed its default color scheme.:colorscheme vim
Disable filetype detectionDetection is on by default in Neovim; this line in init.vim switches it off.:filetype off
Disable syntax highlightingHighlighting is also enabled out of the box and needs this line to be turned off.:syntax off
Disable the mouseA config line; typing : also suspends the mouse while the command line is open.set mouse=
Make right-click extend the selectionReplaces the popup menu that a right click opens by default.set mousemodel=extend
Trust the current fileFor project-local config found by 'exrc': view the file, then run this so Neovim will execute it.:trust

Built-in plugins and packages 14

ActionShortcut
Install and load pluginsLua function for init.lua, new in 0.12: plugins missing from disk are fetched, then each one is loaded.vim.pack.add()
Update pluginsDownloads new changes and opens a confirmation buffer: :write applies the updates, :quit discards them.vim.pack.update()
Delete installed pluginsTakes a list of plugin names; remove their specs from init.lua too, or they are installed again.vim.pack.del()
List managed pluginsReturns information on the plugins vim.pack manages, including whether each is active in this session.vim.pack.get()
Restart and update pluginsRestarts Neovim and runs the update on the fresh instance.:restart lua vim.pack.update()
Load an optional pluginFinds the package in a pack/*/opt directory on 'packpath' and loads it for this session.:packadd {name}
Enable the undo tree pluginThe plugin ships with Neovim 0.12 but is not loaded until this command runs.:packadd nvim.undotree
Toggle the undo tree windowMoving the cursor in that window changes the buffer to the selected undo state.:Undotree
Enable the directory diff pluginNeeded once per session before :DiffTool exists.:packadd nvim.difftool
Compare two directories or filesChanged files are listed in the quickfix list and shown side by side; renames can be detected.:DiffTool {left} {right}
Enable the HTML export pluginThe plugin became opt-in with release 0.12.:packadd nvim.tohtml
Convert buffer to HTMLOpens the generated page in a split; give a file name to save it there instead of a temporary file.:TOhtml
Open a man pageAvailable without setup because the man.lua plugin is enabled by default.:Man
Open a path with the system appUses open on macOS, explorer.exe on Windows and xdg-open on Linux.:Open

Health checks, restart and remote UI 8

ActionShortcut
Run all health checksThe built-in checks cover configuration, performance, the Python and Ruby providers and the clipboard.:checkhealth
Run health checks for named pluginsSeveral names may be given, separated by spaces.:checkhealth {plugins}
Close the health check windowA local mapping that exists only in the :checkhealth report.q
Restart and keep the sessionSaves the session, starts a new Neovim server with the same arguments, restores the session and reattaches the UI.:restart
Restart and discard changesThe +cmd part replaces the :qall that normally stops the old instance.:restart +qall!
Detach the UI from the serverThe Neovim server keeps running in the background and can be reattached to later.:detach
Show the server addressWorth noting before detaching, because reconnecting needs this address.:echo v:servername
Attach the UI to another serverThe UI leaves its current server, which continues to run; add ! to stop that server as well.:connect {address}

Startup options 23

These are typed after nvim on the shell command line; options and file names can be mixed in any order.

ActionShortcut
Start as a fresh installSkips the user config and the ShaDa file but still loads the built-in plugins, unlike -u NONE.--clean
Start without config or pluginsSkips all initialization files, plugins and syntax highlighting.-u NONE
Start without config, keep pluginsInitialization files are skipped as with NONE, while plugins and syntax highlighting still load.-u NORC
Use another config fileReads the named file for initialization and skips most of the usual ones.-u {vimrc}
Skip loading pluginsThe user config is still read; only plugin loading is turned off.--noplugin
Run without a UIFor scripts and tests: no TUI is started and standard input and output stay free for other use.--headless
Run a Lua script and exitArguments after the script name go to the script; user config and plugins are skipped unless asked for.-l {script} [args]
Run Ex commands from stdinSilent batch mode with no UI and most messages off.-es
Open files in diff modeStarts Neovim in diff mode for the files named; the vimdiff alias is the same thing.-d
Open read-onlyThe buffer can still be edited, but writing needs :w! so the file is not overwritten by accident.-R
Open files in horizontal splitsWithout a number, one window is opened per file named on the command line.-o[N]
Open files in vertical splits-O[N]
Open files in tab pagesLimited by 'tabpagemax', which defaults to 50 in Neovim.-p[N]
Start at a line numberA plain + puts the cursor on the last line of the first file.+[num]
Run an Ex command after loadingAlso written +{command}; up to ten may be given and they run in order.-c {command}
Run an Ex command before the configExecutes ahead of any config file, where -c runs after the first file is loaded.--cmd {command}
Source a script after loadingAccepts Vimscript or Lua files; with no name it loads Session.vim.-S [file]
Write startup timing to a fileShows where time goes while the config and plugins load.--startuptime {fname}
Start with verbose messagesReports each sourced file; the level defaults to 10.-V[N]
Start a server at an addressOpens the RPC server on the given pipe or TCP address so other clients and UIs can connect.--listen {addr}
Connect to a running serverCombined with a --remote option to act on that instance instead of starting an editor.--server {addr}
Open files in a running instanceEverything after it is taken as a file name, so other options must come first.--remote {file}
Show a server's UI in this terminalTyping and mouse clicks are passed on, so the remote session is used as if it were local.--remote-ui

Modes and inserting 14

ActionShortcut
Insert before cursorSwitches to Insert mode; typed text goes in front of the character under the cursor.i
Append after cursorLike i, except that typing starts one character further right.a
Insert at start of lineTyping begins at the first non-blank character, so indentation is kept.I
Append at end of lineSaves moving with $ first when something must be added to the end.A
Open line belowCreates an empty line under the current one and switches to Insert mode on it.o
Open line aboveCreates the empty line over the current one instead.O
Insert at last insert positionReturns to the place where Insert mode was left most recently and continues typing there.gi
Enter Replace modeEach typed character overwrites the one under the cursor until Esc is pressed.R
Return to Normal modeEnds Insert, Replace or Visual mode; the first key to press when the editor reacts oddly.Esc
Leave Insert mode, skip abbreviationActs as Esc does but an abbreviation that was just typed is not expanded.Ctrl+C
Start Visual modeSelects by character; move the cursor to grow the selection, then give an operator.v
Start linewise Visual modeWhole lines are selected however the cursor moves inside them.V
Start blockwise Visual modeSelects a rectangle of text, for editing columns.Ctrl+V
Start an Ex commandOpens the command line at the bottom of the screen; Enter runs what was typed.:

Moving the cursor 27

ActionShortcut
Move leftBackspace and the Left arrow move the same way.h
Move downWith a count, goes down that many lines.j
Move upWith a count, goes up that many lines.k
Move rightSpace and the Right arrow move the same way.l
Next word startPunctuation counts as a word of its own; W skips to the next blank-separated word.w
Previous word startb
End of wordStops on the last character of the current or next word.e
Next WORD startA WORD is everything up to the next blank, punctuation included.W
End of previous wordThe backward counterpart of e, landing on the last character of a word.ge
Start of lineGoes to column one even when the line is indented.0
First non-blank of lineSkips leading indentation, which is usually what is wanted in code.^
End of lineA count moves down count minus one lines first.$
Go to first lineA count in front jumps to that line number instead.gg
Go to last lineWith a count it jumps to that line, so 42G lands on line 42.G
Jump to character on lineLands on the next occurrence to the right, within the current line.f{char}
Jump to just before characterStops one position short of the character, handy before d or c.t{char}
Repeat character jumpRuns the latest f, F, t or T again in the same direction.;
Repeat character jump backwardThe same jump as ; but in the reverse direction.,
Next paragraphMoves to the blank line after the current block of text.}
Previous paragraph{
Jump to matching bracketWorks on parentheses, brackets and braces, and on C-style comments and #if blocks.%
Top line of windowA count picks that line counted from the top of the window.H
Bottom line of windowL
Down one screen lineDiffers from j only when a long line is wrapped over several screen lines.gj
Up one screen linegk
Back to enclosing open braceGoes to the { that opens the block the cursor is in.[{
Forward to enclosing close brace]}

Scrolling 9

ActionShortcut
Scroll down one lineThe text moves up while the cursor stays on its line as long as that line is visible.Ctrl+E
Scroll up one lineCtrl+Y
Scroll down half a pageA count changes how many lines this and Ctrl-U scroll from then on.Ctrl+D
Scroll up half a pageCtrl+U
Scroll forward one pageCtrl+F
Scroll back one pageCtrl+B
Center the cursor lineOnly the view changes; the cursor stays on the same text.zz
Put cursor line at topzt
Put cursor line at bottomzb

Editing text 17

ActionShortcut
Delete character under cursorWith a count, removes that many characters going right.x
Delete character before cursorX
Delete lineRemoves the whole line whatever column the cursor is in; a count deletes several lines.dd
Delete to end of lineThe same deletion as typing d$.D
Change lineClears the line and starts Insert mode on it.cc
Change to end of lineThe same change as typing c$.C
Substitute characterRemoves the character under the cursor and starts Insert mode.s
Replace one characterNormal mode is kept, so no Esc is needed afterwards.r{char}
Join linesAppends the next line to the current one with a space between them.J
Toggle case of characterFlips upper and lower case and moves the cursor one step right.~
Indent lineShifts the line right by one 'shiftwidth'; a count indents several lines.>>
Unindent line<<
Reindent lineUses the built-in indenting unless 'equalprg' names an external program.==
Increment numberWorks on the next number found on the line from the cursor onwards; a count adds that much.Ctrl+A
Decrement numberCtrl+X
Suggest spelling correctionsLists replacements for the misspelled word under the cursor to choose from.z=
Next misspelled wordNeeds the 'spell' option to be on.]s

Operators 9

ActionShortcut
Delete over a motionCombine with any motion or text object: dw, d$, dip.d{motion}
Change over a motionDeletes the same text d would and then starts Insert mode.c{motion}
Yank over a motionCopies into a register and leaves the buffer untouched.y{motion}
Indent over a motion>{motion}
Reindent over a motiongg=G reindents a whole file when no external 'equalprg' is set.={motion}
Lowercase over a motiongu{motion}
Uppercase over a motiongU{motion}
Reflow text over a motionWraps the lines to 'textwidth'; gqip formats the current paragraph.gq{motion}
Filter lines through a programThe lines are replaced by what the external command prints for them.!{motion}{command}

Text objects 14

ActionShortcut
Inner wordThe word under the cursor without surrounding space: ciw replaces it from any position inside.iw
A wordIncludes the white space next to the word, so daw leaves clean spacing.aw
Inner paragraphThe block of lines around the cursor up to the nearest blank lines.ip
A paragraphTakes the blank lines after the paragraph as well.ap
Inside parenthesesAlso typed i( or i); the brackets themselves are left out.ib
Around parenthesesThe brackets are part of the object.ab
Inside bracesAlso typed i{ or i}; selects the body of a code block.iB
Around bracesaB
Inside tagThe content between an HTML or XML opening tag and its closing tag.it
Around tagSelects the whole element, opening and closing tag included.at
Inside double quotesThe text of a string on the current line without its quote marks.i"
Around double quotesTakes the quote marks and any white space that trails the string.a"
Inside single quotesi'
Around single quotesa'

Copy, paste and registers 10

ActionShortcut
Yank lineCopies the current line, or as many lines as the count says.yy
Put after cursorWhole lines are pasted below the cursor line.p
Put before cursorWhole lines are pasted above the cursor line.P
Put and move past the textLeaves the cursor behind the pasted text, ready for the next paste.gp
Put with adjusted indentThe pasted lines take the indentation of the cursor line.]p
Use a named registerA prefix for the following yank, delete or put: "ayy copies a line into register a."{char}
Register holding the last yankDeletes do not overwrite it, so "0p pastes the last copied text after a dd."0
System clipboard registerPrefix a yank or put with it to exchange text with other applications."+
Black hole registerDeleting into it keeps the other registers as they are."_
Show register contents:reg

Search and replace 15

ActionShortcut
Search forwardMatches are shown while typing because 'incsearch' is on by default in Neovim; Enter confirms./{pattern}
Search backward?{pattern}
Next matchContinues in the direction the search was started in.n
Previous matchN
Search for word under cursorMatches whole words only and jumps to the next one.*
Search backward for word under cursor#
Go to local declarationSearches the text of the current function; it does not ask a language server, as Ctrl-] does.gd
Select next search matchMakes the match a Visual selection, so cgn changes it and . repeats on the following match.gn
Replace first match on the lineOnly the current line is searched, and only its first occurrence changes.:s/old/new
Replace all matches on the lineThe g flag makes the command act on every occurrence instead of only the first.:s/old/new/g
Replace all matches in the fileThe % range stands for every line of the buffer.:%s/old/new/g
Replace in file with confirmationStops at each match and asks before changing it.:%s/old/new/gc
Repeat substitute on all linesApplies the last :s with its flags to the whole buffer.g&
Run a command on matching linesFollowed by /pattern/ and an Ex command; :g/pattern/d deletes every line that matches.:g
Clear search highlightingThe highlight returns with the next search; Ctrl-L does this too in Neovim.:noh

Visual mode 16

ActionShortcut
Reselect last selectionTyped in Normal mode once the selection is gone, for instance to indent it a second time.gv
Jump to other end of selectionLets the start of the selection be adjusted without selecting again.o
Delete selectiond
Yank selectiony
Change selectionRemoves the selected text and starts Insert mode in its place.c
Replace selection with registerThe replaced text lands in the unnamed register, so a second paste would insert it.p
Replace selection, keep registerUse it to paste the same text over several selections in a row.P
Indent selection>
Unindent selection<
Join selected linesJ
Lowercase selectionu
Uppercase selectionU
Insert before every line of blockBlockwise mode only: type once, press Esc, and the text appears on each selected line.I
Append after every line of blockBlockwise mode only; with $ in the selection the text goes at the end of every line.A
Replace every selected characterr{char}
Run an Ex command on the selectionThe command line opens with the range of the selected lines already filled in.:

Undo, repeat and macros 13

ActionShortcut
UndoSteps back one change at a time; a count undoes several.u
RedoReapplies changes that u took back.Ctrl+R
Undo all changes on lineCounts as a change itself, so u takes it back.U
Repeat last changeReplays the most recent edit at the cursor, including the text that was typed..
Step back in undo historyWalks the undo tree by time, reaching states that plain u can no longer get to.g-
Step forward in undo historyg+
Go back in timeTakes a count of changes or a time such as 10m or 1h.:earlier
Go forward in time:later
Record a macroKeystrokes are stored in the chosen register until q is pressed again.q{a-z}
Stop recordingq
Run a macroA count runs it that many times.@{a-z}
Run the previous macro again@@
Repeat last Ex command@:

Files and buffers 22

ActionShortcut
Edit a fileOpens it in the current window; the buffer shown before stays loaded because 'hidden' is on by default.:e {file}
Reload file from diskRefuses when the buffer has unsaved changes; add ! to throw them away and reload.:e
Find and edit a fileSearches the directories listed in 'path'.:find {file}
Save the file:w
Save under another nameRefuses to overwrite a file that already exists unless ! is added.:w {file}
Save and create parent directoriesThe ++p flag makes missing folders in the file path before writing; Vim has no such flag.:write ++p
Save only if modifiedIn Neovim a buffer for a file that does not exist yet is written even when unmodified.:up
Save all buffers:wa
Quit current windowStops with an error when there are unsaved changes; Neovim exits when the last window closes.:q
Quit and discard changes:q!
Quit all windowsAdd ! to leave even though buffers have unsaved changes.:qa
Save and quitWrites even when nothing changed; :x skips the write in that case.:wq
Save if changed and quitLeaves the file untouched when nothing was modified, unlike :wq.:x
Save if changed and closeThe Normal-mode key for :x.ZZ
Close without savingThe Normal-mode key for :q!.ZQ
Switch to alternate fileToggles between the two files edited most recently in the window.Ctrl+^
Open file named under cursorThe name is looked up in the directories of the 'path' option.gf
List buffersShows the number of each buffer, which :buffer takes as its argument.:ls
Go to a buffer by numberA partial file name works in place of the number.:buffer [N]
Delete a bufferUnloads the buffer and takes it off the buffer list.:bd
Run a shell commandNot suited to interactive programs in Neovim; use :terminal for those.:!{command}
List recently edited filesRead from the ShaDa file, which Neovim uses where Vim has viminfo.:oldfiles

Windows 19

Hover text and diagnostics open in floating windows, and :fclose closes the one on top. Ctrl-W commands spelled with an upper-case letter are left out, since a key cap cannot show case: CTRL-W T, for instance, sends the current window to a tab page of its own.

ActionShortcut
Split windowThe same buffer is shown in both halves, one above the other.Ctrl+WthenS
Split window verticallyThe two windows sit side by side.Ctrl+WthenV
Go to next windowWraps around after the last window.Ctrl+WthenW
Go to previous windowReturns to the window that had the cursor before this one.Ctrl+WthenP
Go to window on the leftThe four direction letters match the h, j, k and l movement keys.Ctrl+WthenH
Go to window belowCtrl+WthenJ
Go to window aboveCtrl+WthenK
Go to window on the rightCtrl+WthenL
Close windowThe buffer stays loaded; the last window cannot be closed this way.Ctrl+WthenC
Quit windowBehaves as :quit, so closing the last window exits Neovim.Ctrl+WthenQ
Close all other windowsCtrl+WthenO
Make windows equal sizeCtrl+Wthen=
Increase window heightA count typed before the chord sets how many lines are added.Ctrl+Wthen+
Decrease window heightCtrl+Wthen-
Increase window widthCtrl+Wthen>
Decrease window widthCtrl+Wthen<
Open a file in a split:split {file}
Open a file in a vertical split:vsplit {file}
Close a floating windowCloses the topmost floating window, such as a hover or diagnostic float; add ! to close them all.:fclose

Tab pages 10

ActionShortcut
Open a new tab pageAdd a file name to edit that file in the new tab.:tabnew
Run a command in a new tabAny command that would open a window opens a tab page instead, as in :tab help.:tab {cmd}
Next tab pageWraps from the last tab page to the first.gt
Previous tab pagegT
Go to tab page by numberTab pages are numbered from one, so 3gt opens the third.{count}gt
Go to last accessed tab pagegthenTab
Last accessed tab page (chord)Ctrl+Tab
Close tab page:tabclose
Close all other tab pages:tabonly
Move tab pageGive a number for the new position; with none the tab page goes to the end.:tabmove

Marks and jumps 12

ActionShortcut
Set a markLowercase marks are local to the buffer; uppercase ones remember the file as well.m{a-zA-Z}
Jump to a markGoes to the exact line and column that were marked.`{a-z}
Jump to a file markOpens the file the mark was set in when it is not the current one.`{A-Z}
Jump to line of a markLands on the first non-blank character of the marked line.'{a-zA-Z0-9}
Jump back to previous positionPressed again it returns, so two places can be visited in turn.``
Jump to last change`.
Go back in jump listGoes back through earlier jumps, across files too.Ctrl+O
Go forward in jump listThe Tab key does the same in Normal mode.Ctrl+I
Go to previous edit locationRevisits the places where text was edited, most recent first.g;
Go to next edit locationg,
List marks:marks
List the jump list:jumps

Folding 13

ActionShortcut
Create a foldFor manual folding; zfap folds the paragraph, for example.zf{motion}
Delete fold at cursorOnly the fold is removed; the lines stay.zd
Open foldOpens a single level; zO opens every nested fold at the cursor.zo
Close foldzc
Toggle foldOpens a closed fold and closes an open one, which makes it the one key to remember.za
Open all foldszR
Close all foldszM
Fold one level lessRaises 'foldlevel' by one, so one more nesting level is shown open.zr
Fold one level morezm
Move to next foldzj
Move to previous foldzk
Toggle folding on or offFlips 'foldenable'; with folding disabled every fold is shown open.zi
Fold by expressionWith 'foldexpr' set to v:lua.vim.treesitter.foldexpr() the folds follow the syntax tree.set foldmethod=expr

Insert mode keys 15

ActionShortcut
Run one Normal-mode commandInsert mode continues by itself once the command has run.Ctrl+O
Insert a registerSince 0.12, named and clipboard registers are inserted literally, as a paste and not as typed keys.Ctrl+Rthen{register}
Insert next character literallyFor a real Tab or a control character that would otherwise be acted on.Ctrl+Vthen{char}
Insert a digraphTwo characters combine into one special character, such as an accented letter.Ctrl+Kthen{char1}then{char2}
Indent current lineWorks from anywhere in the line while typing.Ctrl+T
Unindent current lineCtrl+D
Complete word, next matchSuggests words that begin with the characters typed before the cursor.Ctrl+N
Complete word, previous matchCtrl+P
Complete whole lineOffers lines from the loaded buffers that begin the way the current line does.Ctrl+XthenCtrl+L
Complete file nameUseful for paths: completes the file or directory name being typed.Ctrl+XthenCtrl+F
Complete from dictionaryCtrl+XthenCtrl+K
Complete from registersLooks through all registers for a match with what is typed in front of the cursor.Ctrl+XthenCtrl+R
Complete spelling suggestionLooks at the word before the cursor and offers corrections from the spell checker.Ctrl+XthenS
Accept selected completionWhile the completion menu is open.Ctrl+Y
Cancel completionCloses the menu and restores the text that was typed before completing.Ctrl+E

Command line and help 20

ActionShortcut
Recall matching command from historyOnly entries that begin with the text already typed are shown.UporDown
Complete on the command lineSince 0.12 it also completes in search prompts and in :g, :v and :vimgrep patterns.Tab
List possible completionsCtrl+D
Paste a register into the commandCtrl+Rthen{register}
Insert word under cursorCopies the word at the cursor in the buffer into the command line.Ctrl+RthenCtrl+W
Delete word before cursorCtrl+W
Delete to start of command lineCtrl+U
Abandon the command lineLeaves Command-line mode without running what was typed.Esc
Open command-line windowFrom the command line: the command becomes a buffer line that can be edited with Normal-mode keys.Ctrl+F
Open command history windowTyped in Normal mode; Enter on a line runs that command.q:
Open search history windowq/
Open the help window:help
Open help on a subjectSubjects can be commands, options or keys, such as :help gcc or :help CTRL-W_d-default.:help {subject}
Help for the word at cursorNew in 0.12: guesses the help tag from the text under the cursor.:help!
Look up keyword under cursorRuns 'keywordprg', by default man; in buffers with a language server it shows hover information instead.K
Follow a help linkWith the cursor on a tag in a help file, jumps to the place that tag describes.Ctrl+]
Go back in helpReturns from a tag jump to where the link was followed.Ctrl+T
Search all help filesTakes a pattern; the matches go to the quickfix list.:helpgrep
Show earlier messages:messages
Open the interactive tutorialStarts the built-in lessons in a buffer where the exercises are done in place.:Tutor

Comparing files 8

ActionShortcut
Next changeIn diff mode, moves to the start of the following block of differences.]c
Previous change[c
Obtain change from other bufferPulls the other side's version of the block at the cursor into the current buffer.do
Put change into other bufferdp
Add window to the diffRun it in two windows to compare the buffers they show.:diffthis
Diff current file with anotherGive the other file name; it opens in a new window in diff mode.:diffsplit
Leave diff mode:diffoff
Recompute the differencesNeeded after edits the diff did not follow; Ctrl-L runs it as well in Neovim.:diffupdate

Notes

Modes

Neovim starts in Normal mode, where keys are commands. i enters Insert mode to type text, and Esc returns to Normal — when keys seem to do nothing, Esc first, then retry. v starts a Visual selection by character and V by line; in Visual mode the same edit keys (d, y, >) act on the selection. Command-line mode begins with : and is where files are saved and the editor is quit. Terminal mode belongs to :terminal buffers: every key goes to the shell until Ctrl + \, Ctrl + N brings Normal mode back.

Editing keys Neovim remaps

Y is mapped to y$ at startup, so it copies the rest of the line, starting at the cursor; in Vim the same key is a synonym for yy. In Insert mode, Ctrl + U and Ctrl + W each start a fresh undo step before erasing anything, so the deletion becomes a separate undo step. & repeats the last substitute together with its flags, because Neovim maps it to :&&; the unmapped command does not remember them. [, Space and ], Space add an empty line above or below the cursor while staying in Normal mode. Apart from remapped keys like these, the help describes the editing features of Neovim and Vim as mostly identical.

Search and replace

/{pattern} looks forward and ?{pattern} backward, then n and N step to the next and previous hit; :%s/old/new/g substitutes across the whole file, and :%s/old/new/gc asks for confirmation at each match. Because 'hlsearch' is on by default in Neovim, hits stay highlighted; Ctrl + L clears them, and besides redrawing the screen that key also updates diffs. In Visual mode * and # search for the selected text rather than the word under the cursor, and :grep [args] uses ripgrep when it is installed, since that is what Neovim's 'grepprg' defaults to.

Mappings Neovim creates at startup

gcc toggles a comment on the current line and gc{motion} on the lines a motion covers, with the markers taken from 'commentstring'. Bracket pairs step through lists: ]q and [q for quickfix entries, ]b and [b for buffers, ]d and [d for diagnostics. Q replays the last recorded macro instead of entering Ex mode. Each of these is an ordinary mapping: :unmap Y in the config removes one, and :mapclear early in the config removes them all.

LSP keys need a language server

The gr mappings exist from startup: grn rename, gra code action, grr references, gri implementations, grt type definition, grx code lens. They act only in a buffer with an attached client. Neovim ships the client, not the servers: install a server, describe it with vim.lsp.config() or a file in an lsp/ directory, and switch it on with vim.lsp.enable(). :checkhealth vim.lsp shows whether a client attached. Once it has, K shows hover text, Ctrl + ] goes to the definition and Ctrl + W, D opens the diagnostic at the cursor in a float.

Starting without the config

nvim --clean starts Neovim like a fresh install: no user config and no ShaDa file, with the built-in plugins still loaded. nvim -u NONE also skips plugins and syntax highlighting. When a problem disappears under either, its cause is in the config or in a plugin. :checkhealth reports on configuration, providers and the clipboard, and --startuptime with a file name records where startup time goes.

Questions

How do I exit Neovim?

Press Esc to reach Normal mode, then type :wq and Enter to save and quit, or :q! to quit without saving. ZZ saves the file if it changed and closes the window.

How do I get out of the terminal in Neovim?

Press Ctrl + \, Ctrl + N. The terminal buffer switches to Normal mode, where its output can be scrolled, searched and yanked; i returns to the shell. The manual also gives a mapping for Esc: :tnoremap <Esc> <C-\><C-n>.

Which LSP keys does Neovim define by default?

grn renames, gra opens code actions, grr lists references, gri lists implementations, grt goes to the type definition, grx runs a code lens and gO lists document symbols. In Insert mode Ctrl + S shows signature help, and K shows hover information once a language server is attached.

Why does Y behave differently in Neovim and in Vim?

Neovim sets up Y as y$ at startup, so it yanks from the cursor to the line's end and leaves the start of the line alone. Vim's own Y is a synonym for yy, which takes the whole line. Removing the mapping with :unmap Y in the config gives back Vim's behaviour.

How do I comment out code in Neovim without a plugin?

gcc toggles a comment on the current line, gc followed by a motion (gcip for a paragraph) toggles the lines the motion covers, and gc in Visual mode toggles the selection. The comment markers come from the 'commentstring' option of the filetype.

How do I start Neovim without my configuration?

Run nvim --clean: it skips the user config and the ShaDa file but still loads the built-in plugins. nvim -u NONE also skips plugins and syntax highlighting.

Does Neovim have a built-in plugin manager?

Yes, since release 0.12. Call vim.pack.add() in init.lua with a list of plugin sources; plugins that are missing are downloaded and loaded. vim.pack.update() fetches new versions and shows a confirmation buffer, and vim.pack.del() removes plugins from disk.

Do Vim commands work in Neovim?

The editing commands are the same: motions, operators, text objects, registers, windows and the Ex command line. The differences are in defaults such as Y, Q and Ctrl-L, in the config location (init.lua or init.vim in the nvim config directory) and in additions such as LSP, treesitter, the terminal and Lua.

Sources and checks

22 more source pages

Every row on this page was matched to a line in the documentation above on . A binding that could not be found there is not listed.

401 rows from the earlier version of this page were removed in that check: duplicates, and bindings the documentation does not list or lists differently.

Found a wrong or missing key? Tell us and it gets checked against the source. How we verify describes the process and its limits.