Open a file:
Enter text editing mode (insert mode):
Copy ("yank") or cut ("delete") the current line (paste it with
Enter normal mode and undo the last operation:
Search for a pattern in the file (press
Nto go to next/previous match):
Perform a regular expression substitution in the whole file:
Enter normal mode and save (write) the file, and quit:
Quit without saving:
|nvim||[options] [file ...]|
|nvim||[options] -t tag|
|nvim||[options] -q [errorfile]|
nvim is a text editor based on Vim. Start nvim followed by any number of options and/or files:
nvim [options] [file ...]
Commands in nvim begin with colon (‘:’). Type ":help subject" to get help on a specific subject. Use <Tab> and CTRL-D to complete subjects (":help cmdline-completion").
The "quickref" help section is a condensed reference of editor features:
If you are new to Vim/Nvim, start with the 30-minute tutorial:
After installing/updating Nvim, it's a good idea to run the self-check:
- file ...
File(s) to edit. Opens one buffer per file. To switch between buffers, use the
Reads text from standard input until
EOF, then opens a buffer with that text. User input is read from standard error, which should be a terminal.
- -t tag
Finds tag in the tags file, the associated file becomes the current file and the associated command is executed. Cursor is positioned at the tag location in the file.
- -q [errorfile]
QuickFix mode. Display the first error in errorfile. If errorfile is omitted, the value of the 'errorfile' option is used (defaults to
errors.err). Further errors can be jumped to with the
End of options. Remaining arguments are treated as literal file names, including filenames starting with hyphen (‘-’).
Ex mode, reading stdin as Ex commands.
Ex mode, reading stdin as text.
Silent (non-interactive) Ex mode, reading stdin as Ex commands. Useful for scripting because it does NOT start a UI, unlike -e.
Silent (non-interactive) Ex mode, reading stdin as text. Useful for scripting because it does NOT start a UI, unlike -E.
Diff mode. Show the difference between two to eight files, similar to sdiff(1).
Read-only mode. Sets the 'readonly' option. Implies -n. Buffers can still be edited, but cannot be written to disk if already associated with a file. To overwrite a file, add an exclamation mark to the relevant Ex command, such as
Resets the 'write' option, to disable file modifications. Writing to a file is disabled, but buffers can still be modified.
Resets the 'write' and 'modifiable' options, to disable file and buffer modifications.
Arabic mode. Sets the 'arabic' option.
Hebrew mode. Sets the 'hkmap' and 'rightleft' options.
Verbose mode. Prints debug messages. N is the 'verbose' level, defaults to
10. If file is specified, append messages to file instead of printing them.
Vimscript debug mode. Started when executing the first command from a script. :help debug-mode
Disable the use of swap files. Sets the 'updatecount' option to
0. Can be useful for editing files on a slow medium.
- -r [file]
Recovery mode. If file is omitted then list swap files with recovery information. Otherwise the swap file file is used to recover a crashed session. The swap file has the same name as the file it's associated with, but with ‘.swp’ appended.
- -L [file]
Alias for -r.
- -u vimrc
Use vimrc instead of the default
~/.config/nvim/init.vim. If vimrc is
NORC, do not load any initialization files (except plugins). If vimrc is
NONE, loading plugins is also skipped.
- -i shada
Use shada instead of the default
~/.local/state/nvim/shada/main.shada. If shada is
NONE, do not read or write a ShaDa file.
Skip loading plugins. Implied by
Start Nvim with "factory defaults" (no user config and plugins, no shada).
Open N windows stacked horizontally. If N is omitted, open one window for each file. If N is less than the number of file arguments, allocate windows for the first N files and hide the rest.
Like -o, but tile windows vertically.
Like -o, but for tab pages.
For the first file, position the cursor on line linenum. If linenum is omitted, position the cursor on the last line of the file.
-c 5on the command-line are equivalent to
For the first file, position the cursor on the first occurrence of pattern. If pattern is omitted, the most recent search pattern is used (if any).
-c /fooon the command-line are equivalent to
- +command, -c command
Execute command after reading the first file. Up to 10 instances allowed. "
-c "foo"are equivalent.
- --cmd command
-c, but execute command before processing any vimrc. Up to 10 instances of these can be used independently from instances of
- -l script [args]
Execute Lua script with optional [args] after processing any preceding Nvim startup arguments. All [args] are treated as script arguments and are passed literally to Lua, that is, -l stops processing of Nvim arguments.
- -S [session]
Execute session after the first file argument has been read. If session filename ends with
.luait is executed as Lua instead of Vimscript. Equivalent to
-c "source session". session cannot start with a hyphen (‘-’). If session is omitted then
Session.vimis used, if found.
- -s scriptin
Read normal mode commands from scriptin. The same can be done with the command
:source! scriptin. If the end of the file is reached before nvim exits, further characters are read from the keyboard.
- -w scriptout
Append all typed characters to scriptout. Can be used for creating a script to be used with -s or
- -W scriptout
Like -w, but truncate scriptout.
- --startuptime file
During startup, append timing messages to file. Can be used to diagnose slow startup times.
Dump API metadata serialized to msgpack and exit.
Use standard input and standard output as a msgpack-rpc channel. :help --embed
Do not start a UI. When supplied with --embed this implies that the embedding application does not intend to (immediately) start a UI. Also useful for "scraping" messages in a pipe. :help --headless
- --listen address
Start RPC server on this pipe or TCP socket.
- -h, --help
Print usage information and exit.
- -v, --version
Print version information and exit.
Low-level log file, usually found at ~/.local/state/nvim/log. :help $NVIM_LOG_FILE
Used to locate user files, such as init.vim. System-dependent. :help $VIM
Used to locate runtime files (documentation, syntax highlighting, etc.).
Path to the user-local configuration directory, see Files. Defaults to
~/.config. :help xdg
XDG_CONFIG_HOME, but used to store data not generally edited by the user, namely swap, backup, and ShaDa files. Defaults to
~/.local/state. :help xdg
XDG_CONFIG_HOME, but used to store data not generally edited by the user, things like runtime files. Defaults to
~/.local/share. :help xdg
Ex commands to be executed at startup.
Used to initialize the 'shell' option, which decides the default shell used by features like
User-local nvim configuration file.
User-local nvim configuration directory. See also
System-global nvim configuration file.
System-global nvim runtime directory.
Nvim was started by Thiago de Arruda. Most of Vim was written by Bram Moolenaar. Vim is based on Stevie, worked on by Tim Thompson, Tony Andrews, and G.R. (Fred) Walter.