2017-03-21 09:08:19 -07:00
|
|
|
*starting.txt* Nvim
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
|
|
|
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
|
|
|
|
|
|
|
|
|
|
|
Starting Vim *starting*
|
|
|
|
|
2017-10-20 17:33:58 -07:00
|
|
|
Type |gO| to see the table of contents.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
==============================================================================
|
2021-09-20 19:00:50 -07:00
|
|
|
Nvim arguments *cli-arguments*
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2020-08-31 00:51:35 -07:00
|
|
|
Most often, Nvim is started to edit a single file with the command: >
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2020-08-31 00:51:35 -07:00
|
|
|
nvim filename
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2020-08-31 00:51:35 -07:00
|
|
|
More generally, Nvim is started with: >
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2015-02-17 13:34:15 -07:00
|
|
|
nvim [option | filename] ..
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
Option arguments and file name arguments can be mixed, and any number of them
|
|
|
|
can be given. However, watch out for options that take an argument.
|
|
|
|
|
2020-08-31 00:51:35 -07:00
|
|
|
The following items decide how to start editing:
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*-file* *---*
|
|
|
|
filename One or more file names. The first one will be the current
|
|
|
|
file and read into the buffer. The cursor will be positioned
|
|
|
|
on the first line of the buffer.
|
|
|
|
To avoid a file name starting with a '-' being interpreted as
|
|
|
|
an option, precede the arglist with "--", e.g.: >
|
2015-02-17 13:34:15 -07:00
|
|
|
nvim -- -filename
|
2021-09-20 19:00:50 -07:00
|
|
|
< All arguments after "--" are interpreted as file names, no
|
2022-12-31 19:14:13 -07:00
|
|
|
other options or "+command" arguments can follow.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*--*
|
2022-10-06 06:16:00 -07:00
|
|
|
`-` Alias for stdin (standard input).
|
2017-12-27 11:30:23 -07:00
|
|
|
Example: >
|
|
|
|
echo text | nvim - file
|
|
|
|
< "text" is read into buffer 1, "file" is opened as buffer 2.
|
|
|
|
In most cases (except -s, -es, |--embed|, --headless) if stdin
|
|
|
|
is not a TTY then it is read as text, so "-" is implied: >
|
|
|
|
echo text | nvim file
|
2021-04-26 18:38:12 -07:00
|
|
|
< The buffer will be marked as modified, because it contains
|
|
|
|
text that needs to be saved (except for readonly |-R| mode).
|
|
|
|
If you don't like that, put these lines in your init.vim: >
|
|
|
|
" Don't set 'modified' when reading from stdin
|
|
|
|
au StdinReadPost * set nomodified
|
|
|
|
<
|
2017-12-27 11:30:23 -07:00
|
|
|
To read stdin as Normal commands use |-s| with "-": >
|
|
|
|
echo "ifoo" | nvim -s -
|
|
|
|
< To read stdin as Ex commands use |-es| or |-e|: >
|
|
|
|
echo "echo getpid()" | nvim -e - -V1
|
|
|
|
< To open a file literally named "-", put it after "--": >
|
|
|
|
echo foo | nvim -- -
|
|
|
|
< To read stdin as text with |--headless| use "-".
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*-t* *-tag*
|
|
|
|
-t {tag} A tag. "tag" is looked up in the tags file, the associated
|
|
|
|
file becomes the current file, and the associated command is
|
|
|
|
executed. Mostly this is used for C programs, in which case
|
|
|
|
"tag" often is a function name. The effect is that the file
|
|
|
|
containing that function becomes the current file and the
|
|
|
|
cursor is positioned on the start of the function (see
|
|
|
|
|tags|).
|
|
|
|
|
|
|
|
*-q* *-qf*
|
|
|
|
-q [errorfile] QuickFix mode. The file with the name [errorfile] is read
|
|
|
|
and the first error is displayed. See |quickfix|.
|
|
|
|
If [errorfile] is not given, the 'errorfile' option is used
|
|
|
|
for the file name. See 'errorfile' for the default value.
|
|
|
|
|
|
|
|
(nothing) Without one of the four items above, Vim will start editing a
|
|
|
|
new buffer. It's empty and doesn't have a file name.
|
|
|
|
|
|
|
|
*startup-options*
|
|
|
|
The option arguments may be given in any order. Single-letter options can be
|
|
|
|
combined after one dash. There can be no option arguments after the "--"
|
|
|
|
argument.
|
|
|
|
|
2018-08-27 08:24:33 -07:00
|
|
|
--help *-h* *--help* *-?*
|
|
|
|
-?
|
2015-04-29 17:04:26 -07:00
|
|
|
-h Give usage (help) message and exit.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2015-05-29 20:04:55 -07:00
|
|
|
--version *-v* *--version*
|
|
|
|
-v Print version information and exit. Same output as for
|
2015-04-29 17:04:26 -07:00
|
|
|
|:version| command.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2019-04-15 12:15:36 -07:00
|
|
|
*--clean*
|
2021-10-04 07:01:49 -07:00
|
|
|
--clean Mimics a fresh install of Nvim:
|
2019-04-15 12:15:36 -07:00
|
|
|
- Skips initializations from files and environment variables.
|
|
|
|
- No 'shada' file is read or written.
|
2020-06-07 10:13:52 -07:00
|
|
|
- Excludes user directories from 'runtimepath'
|
2021-10-04 07:01:49 -07:00
|
|
|
- Loads builtin plugins, unlike "-u NONE -i NONE".
|
2019-04-15 12:15:36 -07:00
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
*--noplugin*
|
|
|
|
--noplugin Skip loading plugins. Resets the 'loadplugins' option.
|
|
|
|
Note that the |-u| argument may also disable loading plugins:
|
|
|
|
argument load vimrc files load plugins ~
|
|
|
|
(nothing) yes yes
|
|
|
|
-u NONE no no
|
|
|
|
-u NORC no yes
|
|
|
|
--noplugin yes no
|
|
|
|
|
|
|
|
--startuptime {fname} *--startuptime*
|
|
|
|
During startup write timing messages to the file {fname}.
|
|
|
|
This can be used to find out where time is spent while loading
|
2020-07-19 12:42:02 -07:00
|
|
|
your |config|, plugins and opening the first file.
|
2014-07-10 21:05:51 -07:00
|
|
|
When {fname} already exists new messages are appended.
|
|
|
|
|
|
|
|
*-+*
|
|
|
|
+[num] The cursor will be positioned on line "num" for the first
|
|
|
|
file being edited. If "num" is missing, the cursor will be
|
|
|
|
positioned on the last line.
|
|
|
|
|
|
|
|
*-+/*
|
|
|
|
+/{pat} The cursor will be positioned on the first line containing
|
|
|
|
"pat" in the first file being edited (see |pattern| for the
|
|
|
|
available search patterns). The search starts at the cursor
|
|
|
|
position, which can be the first line or the cursor position
|
2015-07-05 04:08:50 -07:00
|
|
|
last used from |shada|. To force a search from the first
|
2014-07-10 21:05:51 -07:00
|
|
|
line use "+1 +/pat".
|
|
|
|
|
|
|
|
+{command} *-+c* *-c*
|
|
|
|
-c {command} {command} will be executed after the first file has been
|
|
|
|
read (and after autocommands and modelines for that file have
|
|
|
|
been processed). "command" is interpreted as an Ex command.
|
|
|
|
If the "command" contains spaces, it must be enclosed in
|
|
|
|
double quotes (this depends on the shell that is used).
|
|
|
|
Example: >
|
|
|
|
vim "+set si" main.c
|
|
|
|
vim "+find stdio.h"
|
|
|
|
vim -c "set ff=dos" -c wq mine.mak
|
|
|
|
<
|
|
|
|
Note: You can use up to 10 "+" or "-c" arguments in a Vim
|
|
|
|
command. They are executed in the order given. A "-S"
|
|
|
|
argument counts as a "-c" argument as well.
|
|
|
|
|
|
|
|
--cmd {command} *--cmd*
|
|
|
|
{command} will be executed before processing any vimrc file.
|
2024-03-18 15:55:30 -07:00
|
|
|
Otherwise, it acts like -c {command}. You can use up to 10 of
|
2014-07-10 21:05:51 -07:00
|
|
|
these commands, independently from "-c" commands.
|
|
|
|
|
|
|
|
*-S*
|
2022-12-31 19:14:13 -07:00
|
|
|
-S [file] Executes Vimscript or Lua (".lua") [file] after the first file
|
|
|
|
has been read. See also |:source|. If [file] is not given,
|
|
|
|
defaults to "Session.vim". Equivalent to: >
|
2014-07-10 21:05:51 -07:00
|
|
|
-c "source {file}"
|
2022-10-09 05:21:52 -07:00
|
|
|
< Can be repeated like "-c", subject to the same limit of 10
|
|
|
|
"-c" arguments. {file} cannot start with a "-".
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2015-05-29 20:04:55 -07:00
|
|
|
-L *-L* *-r*
|
2014-07-10 21:05:51 -07:00
|
|
|
-r Recovery mode. Without a file name argument, a list of
|
|
|
|
existing swap files is given. With a file name, a swap file
|
|
|
|
is read to recover a crashed editing session. See
|
|
|
|
|crash-recovery|.
|
|
|
|
|
|
|
|
*-R*
|
|
|
|
-R Readonly mode. The 'readonly' option will be set for all the
|
|
|
|
files being edited. You can still edit the buffer, but will
|
|
|
|
be prevented from accidentally overwriting a file. If you
|
|
|
|
forgot that you are in View mode and did make some changes,
|
|
|
|
you can overwrite a file by adding an exclamation mark to
|
|
|
|
the Ex command, as in ":w!". The 'readonly' option can be
|
|
|
|
reset with ":set noro" (see the options chapter, |options|).
|
|
|
|
Subsequent edits will not be done in readonly mode. Calling
|
|
|
|
the executable "view" has the same effect as the -R argument.
|
|
|
|
The 'updatecount' option will be set to 10000, meaning that
|
|
|
|
the swap file will not be updated automatically very often.
|
2017-05-01 04:15:27 -07:00
|
|
|
See |-M| for disallowing modifications.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*-m*
|
|
|
|
-m Modifications not allowed to be written. The 'write' option
|
|
|
|
will be reset, so that writing files is disabled. However,
|
|
|
|
the 'write' option can be set to enable writing again.
|
|
|
|
|
|
|
|
*-M*
|
|
|
|
-M Modifications not allowed. The 'modifiable' option will be
|
|
|
|
reset, so that changes are not allowed. The 'write' option
|
|
|
|
will be reset, so that writing files is disabled. However,
|
|
|
|
the 'modifiable' and 'write' options can be set to enable
|
|
|
|
changes and writing.
|
|
|
|
|
2018-06-03 17:06:32 -07:00
|
|
|
-e *-e* *-E*
|
2022-01-23 10:38:41 -07:00
|
|
|
-E Start Nvim in Ex mode |gQ|, see |Ex-mode|.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2018-06-03 17:06:32 -07:00
|
|
|
If stdin is not a TTY:
|
2019-04-09 04:16:03 -07:00
|
|
|
-e reads/executes stdin as Ex commands.
|
2018-06-03 17:06:32 -07:00
|
|
|
-E reads stdin as text (into buffer 1).
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2019-04-09 04:16:03 -07:00
|
|
|
-es *-es* *-Es* *-s-ex* *silent-mode*
|
2022-12-31 19:14:13 -07:00
|
|
|
-Es Script mode, aka "silent mode", aka "batch mode". No UI,
|
|
|
|
disables most prompts and messages. Unrelated to |-s|.
|
|
|
|
See also |-S| to run script files.
|
2019-04-09 04:16:03 -07:00
|
|
|
|
|
|
|
-es reads/executes stdin as Ex commands. >
|
|
|
|
printf "put ='foo'\n%%print\n" | nvim -es
|
|
|
|
|
|
|
|
< -Es reads stdin as text (into buffer 1). Use |-c| or "+" to
|
|
|
|
send commands. >
|
|
|
|
printf "foo\n" | nvim -Es +"%print"
|
|
|
|
|
2022-10-09 05:21:52 -07:00
|
|
|
< These commands display on stdout:
|
2014-07-10 21:05:51 -07:00
|
|
|
:list
|
|
|
|
:number
|
2022-10-09 05:21:52 -07:00
|
|
|
:print
|
|
|
|
:set
|
|
|
|
With |:verbose| or 'verbose', other commands display on stderr: >
|
|
|
|
nvim -es +":verbose echo 'foo'"
|
|
|
|
nvim -V1 -es +foo
|
2018-06-03 17:06:32 -07:00
|
|
|
|
2021-09-20 19:00:50 -07:00
|
|
|
< User |config| is skipped unless |-u| was given.
|
2019-04-09 04:16:03 -07:00
|
|
|
Swap file is skipped (like |-n|).
|
|
|
|
User |shada| is loaded (unless "-i NONE" is given).
|
2018-06-03 17:06:32 -07:00
|
|
|
|
2021-09-20 19:00:50 -07:00
|
|
|
*-l*
|
|
|
|
-l {script} [args]
|
2022-12-31 19:14:13 -07:00
|
|
|
Executes Lua {script} non-interactively (no UI) with optional
|
|
|
|
[args] after processing any preceding Nvim |cli-arguments|,
|
2023-01-06 18:12:54 -07:00
|
|
|
then exits. Exits 1 on Lua error. See |-S| to run multiple Lua
|
|
|
|
scripts without args, with a UI.
|
2022-12-31 19:14:13 -07:00
|
|
|
*lua-args*
|
2023-01-06 18:12:54 -07:00
|
|
|
All [args] are treated as {script} arguments and stored in the
|
|
|
|
Lua `_G.arg` global table, thus "-l" ends processing of Nvim
|
|
|
|
arguments. The {script} name is stored at `_G.arg[0]`.
|
2023-07-25 05:07:13 -07:00
|
|
|
|
2021-09-20 19:00:50 -07:00
|
|
|
Sets 'verbose' to 1 (like "-V1"), so Lua `print()` writes to
|
|
|
|
output.
|
2023-07-01 14:48:12 -07:00
|
|
|
If {script} prints messages and doesn't cause Nvim to exit,
|
|
|
|
Nvim ensures output ends with a newline.
|
2021-09-20 19:00:50 -07:00
|
|
|
|
2022-12-31 19:14:13 -07:00
|
|
|
Arguments before "-l" are processed before executing {script}.
|
|
|
|
This example quits before executing "foo.lua": >
|
2021-09-20 19:00:50 -07:00
|
|
|
nvim +q -l foo.lua
|
|
|
|
< This loads Lua module "bar" before executing "foo.lua": >
|
|
|
|
nvim +"lua require('bar')" -l foo.lua
|
|
|
|
<
|
2023-01-02 18:54:53 -07:00
|
|
|
Skips user |config| unless |-u| was given.
|
|
|
|
Disables plugins unless 'loadplugins' was set.
|
|
|
|
Disables |shada| unless |-i| was given.
|
|
|
|
Disables swapfile (like |-n|).
|
2021-09-20 19:00:50 -07:00
|
|
|
|
2022-02-26 07:19:10 -07:00
|
|
|
*-ll*
|
|
|
|
-ll {script} [args]
|
2023-06-22 03:44:51 -07:00
|
|
|
Execute a Lua script, similarly to |-l|, but the editor is not
|
|
|
|
initialized. This gives a Lua environment similar to a worker
|
2022-02-26 07:19:10 -07:00
|
|
|
thread. See |lua-loop-threading|.
|
|
|
|
|
|
|
|
Unlike `-l` no prior arguments are allowed.
|
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
*-b*
|
|
|
|
-b Binary mode. File I/O will only recognize <NL> to separate
|
|
|
|
lines. The 'expandtab' option will be reset. The 'textwidth'
|
|
|
|
option is set to 0. 'modeline' is reset. The 'binary' option
|
2020-08-31 00:51:35 -07:00
|
|
|
is set. This is done after reading the |vimrc| but before
|
|
|
|
reading any file in the arglist. See also |edit-binary|.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*-A*
|
2015-04-29 17:04:26 -07:00
|
|
|
-A Arabic mode. Sets the 'arabic' option on.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*-H*
|
2024-03-26 03:30:17 -07:00
|
|
|
-H Hebrew mode. Sets the 'rightleft' option on and the 'keymap'
|
|
|
|
option to "hebrew".
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*-V* *verbose*
|
|
|
|
-V[N] Verbose. Sets the 'verbose' option to [N] (default: 10).
|
|
|
|
Messages will be given for each file that is ":source"d and
|
2015-07-05 04:08:50 -07:00
|
|
|
for reading or writing a ShaDa file. Can be used to find
|
2015-04-29 17:04:26 -07:00
|
|
|
out what is happening upon startup and exit.
|
2014-07-10 21:05:51 -07:00
|
|
|
Example: >
|
2017-11-26 16:35:09 -07:00
|
|
|
nvim -V8
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2021-09-20 19:00:50 -07:00
|
|
|
-V[N]{file}
|
|
|
|
Like -V and sets 'verbosefile' to {file} (must not start with
|
2022-12-31 19:14:13 -07:00
|
|
|
a digit). Messages are not displayed, instead they are
|
2021-09-20 19:00:50 -07:00
|
|
|
written to {file}.
|
2014-07-10 21:05:51 -07:00
|
|
|
Example: >
|
2017-11-26 16:35:09 -07:00
|
|
|
nvim -V20vimlog
|
2014-07-10 21:05:51 -07:00
|
|
|
<
|
|
|
|
*-D*
|
|
|
|
-D Debugging. Go to debugging mode when executing the first
|
|
|
|
command from a script. |debug-mode|
|
|
|
|
|
|
|
|
*-n*
|
2019-04-09 18:27:25 -07:00
|
|
|
-n No |swap-file| will be used. Recovery after a crash will be
|
2014-07-10 21:05:51 -07:00
|
|
|
impossible. Handy if you want to view or edit a file on a
|
|
|
|
very slow medium (e.g., a floppy).
|
|
|
|
Can also be done with ":set updatecount=0". You can switch it
|
|
|
|
on again by setting the 'updatecount' option to some value,
|
|
|
|
e.g., ":set uc=100".
|
|
|
|
'updatecount' is set to 0 AFTER executing commands from a
|
|
|
|
vimrc file, but before the GUI initializations. Thus it
|
|
|
|
overrides a setting for 'updatecount' in a vimrc file, but not
|
|
|
|
in a gvimrc file. See |startup|.
|
|
|
|
When you want to reduce accesses to the disk (e.g., for a
|
|
|
|
laptop), don't use "-n", but set 'updatetime' and
|
|
|
|
'updatecount' to very big numbers, and type ":preserve" when
|
|
|
|
you want to save your work. This way you keep the possibility
|
|
|
|
for crash recovery.
|
|
|
|
|
|
|
|
*-o*
|
|
|
|
-o[N] Open N windows, split horizontally. If [N] is not given,
|
|
|
|
one window is opened for every file given as argument. If
|
|
|
|
there is not enough room, only the first few files get a
|
|
|
|
window. If there are more windows than arguments, the last
|
|
|
|
few windows will be editing an empty file.
|
|
|
|
|
|
|
|
*-O*
|
2024-03-18 15:55:30 -07:00
|
|
|
-O[N] Open N windows, split vertically. Otherwise, it's like -o.
|
2014-07-10 21:05:51 -07:00
|
|
|
If both the -o and the -O option are given, the last one on
|
|
|
|
the command line determines how the windows will be split.
|
|
|
|
|
|
|
|
*-p*
|
|
|
|
-p[N] Open N tab pages. If [N] is not given, one tab page is opened
|
|
|
|
for every file given as argument. The maximum is set with
|
2015-06-20 12:10:29 -07:00
|
|
|
'tabpagemax' pages (default 50). If there are more tab pages
|
2014-07-10 21:05:51 -07:00
|
|
|
than arguments, the last few tab pages will be editing an
|
|
|
|
empty file. Also see |tabpage|.
|
|
|
|
*-d*
|
2015-01-19 17:37:13 -07:00
|
|
|
-d Start in |diff-mode|.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*-u* *E282*
|
|
|
|
-u {vimrc} The file {vimrc} is read for initializations. Most other
|
2019-04-15 12:15:36 -07:00
|
|
|
initializations are skipped; see |initialization|.
|
|
|
|
|
|
|
|
This can be used to start Vim in a special mode, with special
|
2014-07-10 21:05:51 -07:00
|
|
|
mappings and settings. A shell alias can be used to make
|
2024-03-18 15:55:30 -07:00
|
|
|
this easy to use. For example, in a C shell descendant: >
|
|
|
|
alias vimc 'nvim -u ~/.config/nvim/c_init.vim \!*'
|
|
|
|
< And in a Bash shell: >
|
|
|
|
alias vimc='nvim -u ~/.config/nvim/c_init.vim'
|
2014-07-10 21:05:51 -07:00
|
|
|
< Also consider using autocommands; see |autocommand|.
|
2019-04-15 12:15:36 -07:00
|
|
|
|
|
|
|
When {vimrc} is "NONE" (all uppercase), all initializations
|
|
|
|
from files and environment variables are skipped. Plugins and
|
|
|
|
syntax highlighting are also skipped.
|
|
|
|
|
|
|
|
When {vimrc} is "NORC" (all uppercase), this has the same
|
|
|
|
effect as "NONE", but plugins and syntax highlighting are not
|
|
|
|
skipped.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*-i*
|
2015-07-05 04:08:50 -07:00
|
|
|
-i {shada} The file {shada} is used instead of the default ShaDa
|
|
|
|
file. If the name "NONE" is used (all uppercase), no ShaDa
|
2015-07-05 16:26:44 -07:00
|
|
|
file is read or written, even if 'shada' is set or when
|
|
|
|
":rsh" or ":wsh" are used. See also |shada-file|.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*-s*
|
2017-12-27 11:30:23 -07:00
|
|
|
-s {scriptin} Read script file {scriptin}, interpreting characters as
|
|
|
|
Normal-mode input. The same can be done with ":source!": >
|
|
|
|
:source! {scriptin}
|
|
|
|
< Reads from stdin if {scriptin} is "-": >
|
|
|
|
echo "ifoo" | nvim -s -
|
|
|
|
< If the end of the file is reached before Nvim exits, further
|
|
|
|
characters are read from the keyboard.
|
|
|
|
|
|
|
|
Does not work with |-es|. See also |complex-repeat|.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*-w_nr*
|
|
|
|
-w {number}
|
|
|
|
-w{number} Set the 'window' option to {number}.
|
|
|
|
|
|
|
|
*-w*
|
2021-08-22 18:26:35 -07:00
|
|
|
-w {scriptout} All keys that you type are recorded in the file "scriptout",
|
|
|
|
until you exit Vim. Useful to create a script file to be used
|
|
|
|
with "vim -s" or ":source!". Appends to the "scriptout" file
|
|
|
|
if it already exists. {scriptout} cannot start with a digit.
|
|
|
|
See also |vim.on_key()|.
|
|
|
|
See also |complex-repeat|.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*-W*
|
|
|
|
-W {scriptout} Like -w, but do not append, overwrite an existing file.
|
|
|
|
|
2016-06-18 11:12:54 -07:00
|
|
|
*--api-info*
|
2023-02-21 09:07:26 -07:00
|
|
|
--api-info Print msgpack-encoded |api-metadata| and exit.
|
2016-06-18 11:12:54 -07:00
|
|
|
|
2017-12-27 11:30:23 -07:00
|
|
|
*--embed*
|
|
|
|
--embed Use stdin/stdout as a msgpack-RPC channel, so applications can
|
2019-08-25 16:00:58 -07:00
|
|
|
embed and control Nvim via the RPC |API|.
|
2018-09-20 10:19:38 -07:00
|
|
|
|
2019-04-08 18:14:27 -07:00
|
|
|
Waits for the client ("embedder") to call |nvim_ui_attach()|
|
|
|
|
before sourcing startup files and reading buffers, so that UIs
|
|
|
|
can deterministically handle (display) early messages,
|
|
|
|
dialogs, etc. The client can do other requests before
|
|
|
|
`nvim_ui_attach` (e.g. `nvim_get_api_info` for feature-detection).
|
|
|
|
During this pre-startup phase the user config is of course not
|
|
|
|
available (similar to `--cmd`).
|
|
|
|
|
|
|
|
Embedders _not_ using the UI protocol must pass |--headless|: >
|
|
|
|
nvim --embed --headless
|
|
|
|
|
|
|
|
< Then startup will continue without waiting for `nvim_ui_attach`.
|
|
|
|
This is equivalent to: >
|
|
|
|
nvim --headless --cmd "call stdioopen({'rpc': v:true})"
|
2023-10-31 20:04:53 -07:00
|
|
|
<
|
|
|
|
Embedders that use the UI protocol on a socket connection must
|
|
|
|
pass |--listen| as well as |--embed|: >
|
|
|
|
nvim --embed --listen addr
|
2019-04-08 18:14:27 -07:00
|
|
|
|
|
|
|
< See also: |ui-startup| |channel-stdio|
|
2017-12-27 11:30:23 -07:00
|
|
|
|
2017-07-30 12:16:37 -07:00
|
|
|
*--headless*
|
2023-02-21 09:07:26 -07:00
|
|
|
--headless Start without UI, and do not wait for `nvim_ui_attach`. The
|
2019-04-08 18:14:27 -07:00
|
|
|
builtin TUI is not used, so stdio works as an arbitrary
|
2021-09-06 10:35:34 -07:00
|
|
|
communication channel. |channel-stdio|
|
2017-12-27 11:30:23 -07:00
|
|
|
|
|
|
|
Also useful for scripting (tests) to see messages that would
|
|
|
|
not be printed by |-es|.
|
|
|
|
|
|
|
|
To detect if a UI is available, check if |nvim_list_uis()| is
|
2019-04-08 18:14:27 -07:00
|
|
|
empty during or after |VimEnter|.
|
2017-12-27 11:30:23 -07:00
|
|
|
|
|
|
|
To read stdin as text, "-" must be given explicitly:
|
|
|
|
--headless cannot assume that stdin is just text. >
|
|
|
|
echo foo | nvim --headless +"%print" +"q!" -
|
|
|
|
<
|
|
|
|
See also |--embed|.
|
|
|
|
See also |-es|, which also disables most messages.
|
2017-07-30 12:16:37 -07:00
|
|
|
|
2018-04-08 08:20:25 -07:00
|
|
|
--listen {addr} *--listen*
|
2018-04-11 13:07:00 -07:00
|
|
|
Start |RPC| server on pipe or TCP address {addr}. Sets the
|
|
|
|
primary listen address |v:servername| to {addr}. |serverstart()|
|
2018-04-08 08:20:25 -07:00
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
==============================================================================
|
2020-08-31 00:51:35 -07:00
|
|
|
Initialization *initialization* *startup*
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2021-09-02 10:29:59 -07:00
|
|
|
At startup, Nvim checks environment variables and files and sets values
|
|
|
|
accordingly, proceeding as follows:
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2017-05-29 08:14:09 -07:00
|
|
|
1. Set the 'shell' option *SHELL* *COMSPEC*
|
2014-07-10 21:05:51 -07:00
|
|
|
The environment variable SHELL, if it exists, is used to set the
|
2021-04-24 20:14:11 -07:00
|
|
|
'shell' option. On Win32, the COMSPEC variable is used
|
2014-07-10 21:05:51 -07:00
|
|
|
if SHELL is not set.
|
|
|
|
|
|
|
|
2. Process the arguments
|
|
|
|
The options and file names from the command that start Vim are
|
2023-06-11 04:40:22 -07:00
|
|
|
inspected.
|
2014-07-10 21:05:51 -07:00
|
|
|
The |-V| argument can be used to display or log what happens next,
|
|
|
|
useful for debugging the initializations.
|
2023-06-11 04:40:22 -07:00
|
|
|
The |--cmd| arguments are executed.
|
|
|
|
Buffers are created for all files (but not loaded yet).
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2022-10-18 07:18:44 -07:00
|
|
|
3. Start a server (unless |--listen| was given) and set |v:servername|.
|
|
|
|
|
|
|
|
4. Wait for UI to connect.
|
2020-08-31 00:51:35 -07:00
|
|
|
Nvim started with |--embed| waits for the UI to connect before
|
|
|
|
proceeding to load user configuration.
|
|
|
|
|
2022-10-18 07:18:44 -07:00
|
|
|
5. Setup |default-mappings| and |default-autocmds|. Create |popup-menu|.
|
2021-09-02 04:17:04 -07:00
|
|
|
|
2022-10-18 07:18:44 -07:00
|
|
|
6. Enable filetype and indent plugins.
|
2022-01-17 14:11:59 -07:00
|
|
|
This does the same as the command: >
|
2022-01-18 12:46:41 -07:00
|
|
|
:runtime! ftplugin.vim indent.vim
|
2022-01-17 14:11:59 -07:00
|
|
|
< Skipped if the "-u NONE" command line argument was given.
|
|
|
|
|
2022-10-18 07:18:44 -07:00
|
|
|
7. Load user config (execute Ex commands from files, environment, …).
|
2021-07-03 06:31:00 -07:00
|
|
|
$VIMINIT environment variable is read as one Ex command line (separate
|
|
|
|
multiple commands with '|' or <NL>).
|
2020-07-19 12:42:02 -07:00
|
|
|
*config* *init.vim* *init.lua* *vimrc* *exrc*
|
2021-07-03 06:31:00 -07:00
|
|
|
A file containing initialization commands is generically called
|
|
|
|
a "vimrc" or config file. It can be either Vimscript ("init.vim") or
|
|
|
|
Lua ("init.lua"), but not both. *E5422*
|
|
|
|
See also |vimrc-intro| and |base-directories|.
|
2018-12-08 17:31:34 -07:00
|
|
|
|
2021-06-23 00:36:03 -07:00
|
|
|
The config file is located at:
|
2021-07-03 06:31:00 -07:00
|
|
|
Unix ~/.config/nvim/init.vim (or init.lua)
|
|
|
|
Windows ~/AppData/Local/nvim/init.vim (or init.lua)
|
|
|
|
|$XDG_CONFIG_HOME| $XDG_CONFIG_HOME/nvim/init.vim (or init.lua)
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2020-08-31 00:51:35 -07:00
|
|
|
If Nvim was started with "-u {file}" then {file} is used as the config
|
2023-11-23 16:19:06 -07:00
|
|
|
and all initializations until 8. are skipped. $MYVIMRC is not set.
|
2019-01-10 17:20:15 -07:00
|
|
|
"nvim -u NORC" can be used to skip these initializations without
|
|
|
|
reading a file. "nvim -u NONE" also skips plugins and syntax
|
2016-02-13 15:06:33 -07:00
|
|
|
highlighting. |-u|
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2023-11-23 16:19:06 -07:00
|
|
|
If Nvim was started with |-es| or |-Es| or |-l| all initializations until 8.
|
|
|
|
are skipped.
|
2018-12-15 21:40:41 -07:00
|
|
|
*system-vimrc* *sysinit.vim*
|
|
|
|
a. The system vimrc file is read for initializations. If
|
|
|
|
nvim/sysinit.vim file exists in one of $XDG_CONFIG_DIRS, it will be
|
2020-08-31 00:51:35 -07:00
|
|
|
used. Otherwise the system vimrc file is used. The path of this file
|
|
|
|
is given by the |:version| command. Usually it's "$VIM/sysinit.vim".
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2015-10-17 11:53:16 -07:00
|
|
|
*VIMINIT* *EXINIT* *$MYVIMRC*
|
2020-08-31 00:51:35 -07:00
|
|
|
b. Locations searched for initializations, in order of preference:
|
|
|
|
- $VIMINIT environment variable (Ex command line).
|
2022-10-09 05:21:52 -07:00
|
|
|
- User |config|: $XDG_CONFIG_HOME/nvim/init.vim (or init.lua).
|
|
|
|
- Other config: {dir}/nvim/init.vim (or init.lua) where {dir} is any
|
|
|
|
directory in $XDG_CONFIG_DIRS.
|
2020-08-31 00:51:35 -07:00
|
|
|
- $EXINIT environment variable (Ex command line).
|
|
|
|
|$MYVIMRC| is set to the first valid location unless it was already
|
|
|
|
set or when using $VIMINIT.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2017-04-28 12:01:49 -07:00
|
|
|
c. If the 'exrc' option is on (which is NOT the default), the current
|
2022-12-19 09:33:47 -07:00
|
|
|
directory is searched for the following files, in order of precedence:
|
|
|
|
- ".nvim.lua"
|
|
|
|
- ".nvimrc"
|
|
|
|
- ".exrc"
|
|
|
|
The first that exists is used, the others are ignored.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2022-10-18 07:18:44 -07:00
|
|
|
8. Enable filetype detection.
|
2022-01-18 12:46:41 -07:00
|
|
|
This does the same as the command: >
|
2022-10-16 23:52:40 -07:00
|
|
|
:runtime! filetype.lua
|
2022-01-18 12:46:41 -07:00
|
|
|
< Skipped if ":filetype off" was called or if the "-u NONE" command line
|
|
|
|
argument was given.
|
|
|
|
|
2022-10-18 07:18:44 -07:00
|
|
|
9. Enable syntax highlighting.
|
2016-02-13 15:06:33 -07:00
|
|
|
This does the same as the command: >
|
|
|
|
:runtime! syntax/syntax.vim
|
2018-01-03 11:57:22 -07:00
|
|
|
< Skipped if ":syntax off" was called or if the "-u NONE" command
|
|
|
|
line argument was given.
|
2015-05-16 00:10:38 -07:00
|
|
|
|
2022-10-18 07:18:44 -07:00
|
|
|
10. Load the plugin scripts. *load-plugins*
|
2014-07-10 21:05:51 -07:00
|
|
|
This does the same as the command: >
|
2023-07-13 02:17:19 -07:00
|
|
|
:runtime! plugin/**/*.{vim,lua}
|
2021-07-03 06:31:00 -07:00
|
|
|
< The result is that all directories in 'runtimepath' will be searched
|
|
|
|
for the "plugin" sub-directory and all files ending in ".vim" or
|
|
|
|
".lua" will be sourced (in alphabetical order per directory),
|
2023-07-13 02:17:19 -07:00
|
|
|
also in subdirectories. First "*.vim" are sourced, then "*.lua" files,
|
|
|
|
per directory.
|
2021-07-03 06:31:00 -07:00
|
|
|
|
2017-03-21 09:07:00 -07:00
|
|
|
However, directories in 'runtimepath' ending in "after" are skipped
|
|
|
|
here and only loaded after packages, see below.
|
2014-07-10 21:05:51 -07:00
|
|
|
Loading plugins won't be done when:
|
2022-12-28 05:39:39 -07:00
|
|
|
- The |'loadplugins'| option was reset in a vimrc file.
|
2014-07-10 21:05:51 -07:00
|
|
|
- The |--noplugin| command line argument is used.
|
2019-04-15 12:15:36 -07:00
|
|
|
- The |--clean| command line argument is used.
|
2014-07-10 21:05:51 -07:00
|
|
|
- The "-u NONE" command line argument is used |-u|.
|
2022-12-28 05:39:39 -07:00
|
|
|
Note that using `-c 'set noloadplugins'` doesn't work, because the
|
2014-07-10 21:05:51 -07:00
|
|
|
commands from the command line have not been executed yet. You can
|
2022-12-28 05:39:39 -07:00
|
|
|
use `--cmd 'set noloadplugins'` or `--cmd 'set loadplugins'` |--cmd|.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2016-07-07 20:26:00 -07:00
|
|
|
Packages are loaded. These are plugins, as above, but found in the
|
|
|
|
"start" directory of each entry in 'packpath'. Every plugin directory
|
|
|
|
found is added in 'runtimepath' and then the plugins are sourced. See
|
|
|
|
|packages|.
|
2016-04-25 20:07:51 -07:00
|
|
|
|
2017-03-21 09:07:00 -07:00
|
|
|
The plugins scripts are loaded, as above, but now only the directories
|
|
|
|
ending in "after" are used. Note that 'runtimepath' will have changed
|
|
|
|
if packages have been found, but that should not add a directory
|
|
|
|
ending in "after".
|
|
|
|
|
2022-10-18 07:18:44 -07:00
|
|
|
11. Set 'shellpipe' and 'shellredir'
|
2014-07-10 21:05:51 -07:00
|
|
|
The 'shellpipe' and 'shellredir' options are set according to the
|
|
|
|
value of the 'shell' option, unless they have been set before.
|
2021-09-02 10:29:59 -07:00
|
|
|
This means that Nvim will figure out the values of 'shellpipe' and
|
2014-07-10 21:05:51 -07:00
|
|
|
'shellredir' for you, unless you have set them yourself.
|
|
|
|
|
2024-03-18 15:55:30 -07:00
|
|
|
12. Set 'updatecount' to zero, if "-n" command argument used.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2022-10-18 07:18:44 -07:00
|
|
|
13. Set binary options if the |-b| flag was given.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2022-10-18 07:18:44 -07:00
|
|
|
14. Read the |shada-file|.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2022-10-18 07:18:44 -07:00
|
|
|
15. Read the quickfix file if the |-q| flag was given, or exit on failure.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2022-10-18 07:18:44 -07:00
|
|
|
16. Open all windows
|
2014-07-10 21:05:51 -07:00
|
|
|
When the |-o| flag was given, windows will be opened (but not
|
|
|
|
displayed yet).
|
|
|
|
When the |-p| flag was given, tab pages will be created (but not
|
|
|
|
displayed yet).
|
|
|
|
When switching screens, it happens now. Redrawing starts.
|
2021-09-02 10:29:59 -07:00
|
|
|
If the |-q| flag was given, the first error is jumped to.
|
2021-04-24 17:59:08 -07:00
|
|
|
Buffers for all windows will be loaded, without triggering |BufAdd|
|
|
|
|
autocommands.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2022-10-18 07:18:44 -07:00
|
|
|
17. Execute startup commands
|
2021-09-02 10:29:59 -07:00
|
|
|
If a |-t| flag was given, the tag is jumped to.
|
|
|
|
Commands given with |-c| and |+cmd| are executed.
|
2016-06-22 19:05:27 -07:00
|
|
|
The starting flag is reset, has("vim_starting") will now return zero.
|
|
|
|
The |v:vim_did_enter| variable is set to 1.
|
2014-07-10 21:05:51 -07:00
|
|
|
The |VimEnter| autocommands are executed.
|
|
|
|
|
2017-04-29 04:58:49 -07:00
|
|
|
|
|
|
|
Saving the current state of Vim to a file ~
|
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
Whenever you have changed values of options or when you have created a
|
|
|
|
mapping, then you may want to save them in a vimrc file for later use. See
|
|
|
|
|save-settings| about saving the current state of settings to a file.
|
|
|
|
|
2017-04-29 04:58:49 -07:00
|
|
|
|
|
|
|
Avoiding trojan horses ~
|
|
|
|
*trojan-horse*
|
|
|
|
While reading the "vimrc" or the "exrc" file in the current directory, some
|
2014-07-10 21:05:51 -07:00
|
|
|
commands can be disabled for security reasons by setting the 'secure' option.
|
2024-03-18 15:55:30 -07:00
|
|
|
This is always done when executing the command from a tags file. Otherwise,
|
|
|
|
it would be possible that you accidentally use a vimrc or tags file that
|
|
|
|
somebody else created and contains nasty commands. The disabled commands are
|
|
|
|
the ones that start a shell, the ones that write to a file, and ":autocmd".
|
|
|
|
The ":map" commands are echoed, so you can see which keys are being mapped.
|
2014-07-10 21:05:51 -07:00
|
|
|
If you want Vim to execute all commands in a local vimrc file, you
|
|
|
|
can reset the 'secure' option in the EXINIT or VIMINIT environment variable or
|
2015-10-17 07:25:53 -07:00
|
|
|
in the global exrc or vimrc file. This is not possible in vimrc or
|
|
|
|
exrc in the current directory, for obvious reasons.
|
2014-07-10 21:05:51 -07:00
|
|
|
On Unix systems, this only happens if you are not the owner of the
|
|
|
|
vimrc file. Warning: If you unpack an archive that contains a vimrc or exrc
|
|
|
|
file, it will be owned by you. You won't have the security protection. Check
|
|
|
|
the vimrc file before you start Vim in that directory, or reset the 'exrc'
|
|
|
|
option. Some Unix systems allow a user to do "chown" on a file. This makes
|
|
|
|
it possible for another user to create a nasty vimrc and make you the owner.
|
|
|
|
Be careful!
|
|
|
|
When using tag search commands, executing the search command (the last
|
|
|
|
part of the line in the tags file) is always done in secure mode. This works
|
2020-08-31 00:51:35 -07:00
|
|
|
just like executing a command from a vimrc in the current directory.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2017-04-29 04:58:49 -07:00
|
|
|
|
|
|
|
If Vim startup is slow ~
|
2014-07-10 21:05:51 -07:00
|
|
|
*slow-start*
|
|
|
|
If Vim takes a long time to start up, use the |--startuptime| argument to find
|
2015-05-29 20:26:27 -07:00
|
|
|
out what happens.
|
|
|
|
|
2015-07-05 16:26:44 -07:00
|
|
|
If you have 'shada' enabled, the loading of the ShaDa file may take a
|
2015-07-05 16:16:05 -07:00
|
|
|
while. You can find out if this is the problem by disabling ShaDa for a
|
2015-05-29 20:26:27 -07:00
|
|
|
moment (use the Vim argument "-i NONE", |-i|). Try reducing the number of
|
2015-07-05 16:26:44 -07:00
|
|
|
lines stored in a register with ":set shada='20,<50,s10". |shada-file|.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2017-04-29 04:58:49 -07:00
|
|
|
|
2020-08-31 00:51:35 -07:00
|
|
|
Troubleshooting broken configurations ~
|
|
|
|
*bisect*
|
|
|
|
The extreme flexibility of editors like Vim and Emacs means that any plugin or
|
|
|
|
setting can affect the entire editor in ways that are not initially obvious.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2020-08-31 00:51:35 -07:00
|
|
|
To find the cause of a problem in your config, you must "bisect" it:
|
2020-07-19 12:42:02 -07:00
|
|
|
1. Remove or disable half of your |config|.
|
2020-08-31 00:51:35 -07:00
|
|
|
2. Restart Nvim.
|
2021-09-06 10:35:34 -07:00
|
|
|
3. If the problem still occurs, goto 1.
|
2020-08-31 00:51:35 -07:00
|
|
|
4. If the problem is gone, restore half of the removed lines.
|
|
|
|
5. Continue narrowing your config in this way, until you find the setting or
|
|
|
|
plugin causing the issue.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
|
2020-08-31 00:51:35 -07:00
|
|
|
Intro message ~
|
|
|
|
*:intro*
|
|
|
|
When Vim starts without a file name, an introductory message is displayed. It
|
|
|
|
is removed as soon as the display is redrawn. To see the message again, use
|
|
|
|
the ":intro" command. To avoid the intro message on startup, add the "I" flag
|
|
|
|
to 'shortmess'.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
==============================================================================
|
2020-08-31 00:51:35 -07:00
|
|
|
$VIM and $VIMRUNTIME
|
2014-07-10 21:05:51 -07:00
|
|
|
*$VIM*
|
2017-10-15 14:23:17 -07:00
|
|
|
The environment variable "$VIM" is used to locate various user files for Nvim,
|
2020-07-19 12:42:02 -07:00
|
|
|
such as the user |config|. This depends on the system, see
|
2014-07-10 21:05:51 -07:00
|
|
|
|startup|.
|
|
|
|
|
2017-10-15 14:23:17 -07:00
|
|
|
Nvim will try to get the value for $VIM in this order:
|
|
|
|
|
|
|
|
1. Environment variable $VIM, if it is set.
|
|
|
|
2. Path derived from the 'helpfile' option, unless it contains some
|
|
|
|
environment variable too (default is "$VIMRUNTIME/doc/help.txt"). File
|
|
|
|
name ("help.txt", etc.) is removed. Trailing directory names are removed,
|
|
|
|
in this order: "doc", "runtime".
|
|
|
|
3. Path derived from the location of the `nvim` executable.
|
|
|
|
4. Compile-time defined installation directory (see output of ":version").
|
|
|
|
|
|
|
|
After doing this once, Nvim sets the $VIM environment variable.
|
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
*$VIMRUNTIME*
|
|
|
|
The environment variable "$VIMRUNTIME" is used to locate various support
|
2017-10-15 14:23:17 -07:00
|
|
|
files, such as the documentation and syntax-highlighting files. For example,
|
|
|
|
the main help file is normally "$VIMRUNTIME/doc/help.txt".
|
|
|
|
|
|
|
|
Nvim will try to get the value for $VIMRUNTIME in this order:
|
|
|
|
|
|
|
|
1. Environment variable $VIMRUNTIME, if it is set.
|
|
|
|
2. Directory path "$VIM/vim{version}", if it exists, where {version} is the
|
2021-04-25 08:56:17 -07:00
|
|
|
Vim version number without '-' or '.'. For example: "$VIM/vim82".
|
2017-10-15 14:23:17 -07:00
|
|
|
3. Directory path "$VIM/runtime", if it exists.
|
|
|
|
4. Value of $VIM environment variable. This is for backwards compatibility
|
|
|
|
with older Vim versions.
|
2017-03-05 20:04:25 -07:00
|
|
|
5. If "../share/nvim/runtime" exists relative to |v:progpath|, it is used.
|
2017-10-15 14:23:17 -07:00
|
|
|
6. Path derived from the 'helpfile' option (if it doesn't contain '$') with
|
|
|
|
"doc/help.txt" removed from the end.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2017-10-15 14:23:17 -07:00
|
|
|
After doing this once, Nvim sets the $VIMRUNTIME environment variable.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
In case you need the value of $VIMRUNTIME in a shell (e.g., for a script that
|
|
|
|
greps in the help files) you might be able to use this: >
|
|
|
|
|
2019-08-01 22:34:39 -07:00
|
|
|
VIMRUNTIME="$(nvim --clean --headless --cmd 'echo $VIMRUNTIME|q')"
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
==============================================================================
|
2020-08-31 00:51:35 -07:00
|
|
|
Suspending *suspend*
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2020-08-31 00:51:35 -07:00
|
|
|
*CTRL-Z* *v_CTRL-Z*
|
2018-08-04 18:17:08 -07:00
|
|
|
CTRL-Z Suspend Nvim, like ":stop".
|
2014-07-10 21:05:51 -07:00
|
|
|
Works in Normal and in Visual mode. In Insert and
|
|
|
|
Command-line mode, the CTRL-Z is inserted as a normal
|
2018-08-04 18:17:08 -07:00
|
|
|
character. In Visual mode Nvim goes back to Normal
|
2014-07-10 21:05:51 -07:00
|
|
|
mode.
|
|
|
|
|
|
|
|
:sus[pend][!] or *:sus* *:suspend* *:st* *:stop*
|
2018-08-04 18:17:08 -07:00
|
|
|
:st[op][!] Suspend Nvim using OS "job control"; it will continue
|
|
|
|
if you make it the foreground job again. Triggers
|
|
|
|
|VimSuspend| before suspending and |VimResume| when
|
|
|
|
resumed.
|
|
|
|
If "!" is not given and 'autowrite' is set, every
|
2014-07-10 21:05:51 -07:00
|
|
|
buffer with changes and a file name is written out.
|
2018-08-04 18:17:08 -07:00
|
|
|
If "!" is given or 'autowrite' is not set, changed
|
|
|
|
buffers are not written, don't forget to bring Nvim
|
2014-07-10 21:05:51 -07:00
|
|
|
back to the foreground later!
|
|
|
|
|
2018-04-14 06:51:22 -07:00
|
|
|
In the GUI, suspending is implementation-defined.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
==============================================================================
|
2020-08-31 00:51:35 -07:00
|
|
|
Exiting *exiting*
|
2016-06-07 09:06:20 -07:00
|
|
|
|
|
|
|
There are several ways to exit Vim:
|
|
|
|
- Close the last window with `:quit`. Only when there are no changes.
|
|
|
|
- Close the last window with `:quit!`. Also when there are changes.
|
|
|
|
- Close all windows with `:qall`. Only when there are no changes.
|
|
|
|
- Close all windows with `:qall!`. Also when there are changes.
|
|
|
|
- Use `:cquit`. Also when there are changes.
|
|
|
|
|
|
|
|
When using `:cquit` or when there was an error message Vim exits with exit
|
2017-05-01 04:15:27 -07:00
|
|
|
code 1. Errors can be avoided by using `:silent!` or with `:catch`.
|
2016-06-07 09:06:20 -07:00
|
|
|
|
|
|
|
==============================================================================
|
2020-08-31 00:51:35 -07:00
|
|
|
Saving settings *save-settings*
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
Mostly you will edit your vimrc files manually. This gives you the greatest
|
|
|
|
flexibility. There are a few commands to generate a vimrc file automatically.
|
|
|
|
You can use these files as they are, or copy/paste lines to include in another
|
|
|
|
vimrc file.
|
|
|
|
|
|
|
|
*:mk* *:mkexrc*
|
|
|
|
:mk[exrc] [file] Write current key mappings and changed options to
|
|
|
|
[file] (default ".exrc" in the current directory),
|
2015-04-29 17:04:26 -07:00
|
|
|
unless it already exists.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
:mk[exrc]! [file] Always write current key mappings and changed
|
|
|
|
options to [file] (default ".exrc" in the current
|
2015-04-29 17:04:26 -07:00
|
|
|
directory).
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2019-08-01 21:44:48 -07:00
|
|
|
*:mkv* *:mkvi* *:mkvimrc*
|
2015-10-17 07:25:53 -07:00
|
|
|
:mkv[imrc][!] [file] Like ":mkexrc", but the default is ".nvimrc" in the
|
2014-07-10 21:05:51 -07:00
|
|
|
current directory. The ":version" command is also
|
2015-04-29 17:04:26 -07:00
|
|
|
written to the file.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
These commands will write ":map" and ":set" commands to a file, in such a way
|
|
|
|
that when these commands are executed, the current key mappings and options
|
|
|
|
will be set to the same values. The options 'columns', 'endofline',
|
2021-09-06 10:35:34 -07:00
|
|
|
'fileformat', 'lines', 'modified', and 'scroll' are not included, because
|
2016-02-10 04:11:33 -07:00
|
|
|
these are terminal or file dependent.
|
2015-05-05 19:00:43 -07:00
|
|
|
Note that the options 'binary', 'paste' and 'readonly' are included, this
|
|
|
|
might not always be what you want.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2024-03-18 15:55:30 -07:00
|
|
|
When special keys are used in mappings, the 'cpoptions' option will be
|
2014-07-10 21:05:51 -07:00
|
|
|
temporarily set to its Vim default, to avoid the mappings to be
|
|
|
|
misinterpreted. This makes the file incompatible with Vi, but makes sure it
|
|
|
|
can be used with different terminals.
|
|
|
|
|
|
|
|
Only global mappings are stored, not mappings local to a buffer.
|
|
|
|
|
2020-07-19 12:42:02 -07:00
|
|
|
A common method is to use a default |config| file, make some modifications
|
2014-07-10 21:05:51 -07:00
|
|
|
with ":map" and ":set" commands and write the modified file. First read the
|
2015-10-17 07:25:53 -07:00
|
|
|
default vimrc in with a command like ":source ~piet/.vimrc.Cprogs", change
|
2014-07-10 21:05:51 -07:00
|
|
|
the settings and then save them in the current directory with ":mkvimrc!". If
|
2020-07-19 12:42:02 -07:00
|
|
|
you want to make this file your default |config|, move it to
|
2021-09-06 10:35:34 -07:00
|
|
|
$XDG_CONFIG_HOME/nvim. You could also use autocommands |autocommand| and/or
|
2015-10-17 07:25:53 -07:00
|
|
|
modelines |modeline|.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*vimrc-option-example*
|
|
|
|
If you only want to add a single option setting to your vimrc, you can use
|
|
|
|
these steps:
|
|
|
|
1. Edit your vimrc file with Vim.
|
|
|
|
2. Play with the option until it's right. E.g., try out different values for
|
|
|
|
'guifont'.
|
|
|
|
3. Append a line to set the value of the option, using the expression register
|
|
|
|
'=' to enter the value. E.g., for the 'guifont' option: >
|
|
|
|
o:set guifont=<C-R>=&guifont<CR><Esc>
|
|
|
|
< [<C-R> is a CTRL-R, <CR> is a return, <Esc> is the escape key]
|
|
|
|
You need to escape special characters, esp. spaces.
|
|
|
|
|
|
|
|
==============================================================================
|
2020-08-31 00:51:35 -07:00
|
|
|
Views and Sessions *views-sessions*
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
This is introduced in sections |21.4| and |21.5| of the user manual.
|
|
|
|
|
|
|
|
*View* *view-file*
|
|
|
|
A View is a collection of settings that apply to one window. You can save a
|
|
|
|
View and when you restore it later, the text is displayed in the same way.
|
|
|
|
The options and mappings in this window will also be restored, so that you can
|
|
|
|
continue editing like when the View was saved.
|
|
|
|
|
|
|
|
*Session* *session-file*
|
|
|
|
A Session keeps the Views for all windows, plus the global settings. You can
|
|
|
|
save a Session and when you restore it later the window layout looks the same.
|
|
|
|
You can use a Session to quickly switch between different projects,
|
|
|
|
automatically loading the files you were last working on in that project.
|
|
|
|
|
2015-07-05 04:08:50 -07:00
|
|
|
Views and Sessions are a nice addition to ShaDa files, which are used to
|
|
|
|
remember information for all Views and Sessions together |shada-file|.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
You can quickly start editing with a previously saved View or Session with the
|
|
|
|
|-S| argument: >
|
|
|
|
vim -S Session.vim
|
|
|
|
<
|
|
|
|
*:mks* *:mksession*
|
|
|
|
:mks[ession][!] [file] Write a Vim script that restores the current editing
|
|
|
|
session.
|
2024-03-18 15:55:30 -07:00
|
|
|
When [!] is included, an existing file is overwritten.
|
|
|
|
When [file] is omitted, "Session.vim" is used.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
The output of ":mksession" is like ":mkvimrc", but additional commands are
|
|
|
|
added to the file. Which ones depends on the 'sessionoptions' option. The
|
|
|
|
resulting file, when executed with a ":source" command:
|
|
|
|
1. Restores global mappings and options, if 'sessionoptions' contains
|
|
|
|
"options". Script-local mappings will not be written.
|
|
|
|
2. Restores global variables that start with an uppercase letter and contain
|
|
|
|
at least one lowercase letter, if 'sessionoptions' contains "globals".
|
2021-05-01 20:21:50 -07:00
|
|
|
3. Closes all windows in the current tab page, except the current one; closes
|
|
|
|
all tab pages except the current one (this results in currently loaded
|
|
|
|
buffers to be unloaded, some may become hidden if 'hidden' is set or
|
2024-03-18 15:55:30 -07:00
|
|
|
otherwise specified); wipes out the current buffer, if it is empty and
|
|
|
|
unnamed.
|
|
|
|
4. Restores the current directory, if 'sessionoptions' contains "curdir", or
|
|
|
|
sets the current directory to where the Session file is, if
|
|
|
|
'sessionoptions' contains "sesdir".
|
2014-07-10 21:05:51 -07:00
|
|
|
5. Restores GUI Vim window position, if 'sessionoptions' contains "winpos".
|
|
|
|
6. Restores screen size, if 'sessionoptions' contains "resize".
|
|
|
|
7. Reloads the buffer list, with the last cursor positions. If
|
|
|
|
'sessionoptions' contains "buffers" then all buffers are restored,
|
2024-03-18 15:55:30 -07:00
|
|
|
including hidden and unloaded buffers. Otherwise, only buffers in windows
|
2014-07-10 21:05:51 -07:00
|
|
|
are restored.
|
|
|
|
8. Restores all windows with the same layout. If 'sessionoptions' contains
|
|
|
|
"help", help windows are restored. If 'sessionoptions' contains "blank",
|
|
|
|
windows editing a buffer without a name will be restored.
|
|
|
|
If 'sessionoptions' contains "winsize" and no (help/blank) windows were
|
|
|
|
left out, the window sizes are restored (relative to the screen size).
|
|
|
|
Otherwise, the windows are just given sensible sizes.
|
|
|
|
9. Restores the Views for all the windows, as with |:mkview|. But
|
|
|
|
'sessionoptions' is used instead of 'viewoptions'.
|
|
|
|
10. If a file exists with the same name as the Session file, but ending in
|
2023-06-24 04:47:10 -07:00
|
|
|
"x.vim" (for eXtra), executes that as well. You can use `*x.vim` files to
|
2014-07-10 21:05:51 -07:00
|
|
|
specify additional settings and actions associated with a given Session,
|
|
|
|
such as creating menu items in the GUI version.
|
|
|
|
|
|
|
|
After restoring the Session, the full filename of your current Session is
|
2018-07-22 18:18:10 -07:00
|
|
|
available in the internal variable |v:this_session|.
|
2014-07-10 21:05:51 -07:00
|
|
|
An example mapping: >
|
2022-02-27 03:56:30 -07:00
|
|
|
:nmap <F2> :wa<Bar>exe "mksession! " .. v:this_session<CR>:so ~/sessions/
|
2014-07-10 21:05:51 -07:00
|
|
|
This saves the current Session, and starts off the command to load another.
|
|
|
|
|
|
|
|
A session includes all tab pages, unless "tabpages" was removed from
|
|
|
|
'sessionoptions'. |tab-page|
|
|
|
|
|
|
|
|
The |SessionLoadPost| autocmd event is triggered after a session file is
|
|
|
|
loaded/sourced.
|
|
|
|
*SessionLoad-variable*
|
2024-03-18 15:55:30 -07:00
|
|
|
While the session file is loading, the SessionLoad global variable is set to
|
|
|
|
1. Plugins can use this to postpone some work until the SessionLoadPost event
|
|
|
|
is triggered.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
*:mkvie* *:mkview*
|
|
|
|
:mkvie[w][!] [file] Write a Vim script that restores the contents of the
|
|
|
|
current window.
|
2024-03-18 15:55:30 -07:00
|
|
|
When [!] is included, an existing file is overwritten.
|
2014-07-10 21:05:51 -07:00
|
|
|
When [file] is omitted or is a number from 1 to 9, a
|
|
|
|
name is generated and 'viewdir' prepended. When the
|
|
|
|
last path part of 'viewdir' does not exist, this
|
|
|
|
directory is created. E.g., when 'viewdir' is
|
|
|
|
"$VIM/vimfiles/view" then "view" is created in
|
|
|
|
"$VIM/vimfiles".
|
|
|
|
An existing file is always overwritten then. Use
|
|
|
|
|:loadview| to load this view again.
|
|
|
|
When [file] is the name of a file ('viewdir' is not
|
|
|
|
used), a command to edit the file is added to the
|
|
|
|
generated file.
|
|
|
|
|
|
|
|
The output of ":mkview" contains these items:
|
|
|
|
1. The argument list used in the window. When the global argument list is
|
2024-03-18 15:55:30 -07:00
|
|
|
used, it is reset to the global list.
|
2014-07-10 21:05:51 -07:00
|
|
|
The index in the argument list is also restored.
|
|
|
|
2. The file being edited in the window. If there is no file, the window is
|
|
|
|
made empty.
|
2024-03-18 15:55:30 -07:00
|
|
|
3. Restore mappings, abbreviations and options local to the window, if
|
|
|
|
'viewoptions' contains "options" or "localoptions". Only option values
|
|
|
|
that are local to the current buffer and the current window are restored.
|
2014-07-10 21:05:51 -07:00
|
|
|
When storing the view as part of a session and "options" is in
|
|
|
|
'sessionoptions', global values for local options will be stored too.
|
|
|
|
4. Restore folds when using manual folding and 'viewoptions' contains
|
|
|
|
"folds". Restore manually opened and closed folds.
|
|
|
|
5. The scroll position and the cursor position in the file. Doesn't work very
|
|
|
|
well when there are closed folds.
|
|
|
|
6. The local current directory, if it is different from the global current
|
2017-10-27 07:48:24 -07:00
|
|
|
directory and 'viewoptions' contains "curdir".
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
Note that Views and Sessions are not perfect:
|
|
|
|
- They don't restore everything. For example, defined functions, autocommands
|
|
|
|
and ":syntax on" are not included. Things like register contents and
|
2015-07-05 04:08:50 -07:00
|
|
|
command line history are in ShaDa, not in Sessions or Views.
|
2014-07-10 21:05:51 -07:00
|
|
|
- Global option values are only set when they differ from the default value.
|
|
|
|
When the current value is not the default value, loading a Session will not
|
|
|
|
set it back to the default value. Local options will be set back to the
|
|
|
|
default value though.
|
|
|
|
- Existing mappings will be overwritten without warning. An existing mapping
|
|
|
|
may cause an error for ambiguity.
|
|
|
|
- When storing manual folds and when storing manually opened/closed folds,
|
|
|
|
changes in the file between saving and loading the view will mess it up.
|
|
|
|
- The Vim script is not very efficient. But still faster than typing the
|
|
|
|
commands yourself!
|
|
|
|
|
|
|
|
*:lo* *:loadview*
|
|
|
|
:lo[adview] [nr] Load the view for the current file. When [nr] is
|
|
|
|
omitted, the view stored with ":mkview" is loaded.
|
|
|
|
When [nr] is specified, the view stored with ":mkview
|
|
|
|
[nr]" is loaded.
|
|
|
|
|
|
|
|
The combination of ":mkview" and ":loadview" can be used to store up to ten
|
|
|
|
different views of a file. These are remembered in the directory specified
|
|
|
|
with the 'viewdir' option. The views are stored using the file name. If a
|
2024-03-18 15:55:30 -07:00
|
|
|
file is renamed or accessed through a (symbolic) link, the view will not be
|
2014-07-10 21:05:51 -07:00
|
|
|
found.
|
|
|
|
|
|
|
|
You might want to clean up your 'viewdir' directory now and then.
|
|
|
|
|
2023-06-24 04:47:10 -07:00
|
|
|
To automatically save and restore views for `*.c` files: >
|
2014-07-10 21:05:51 -07:00
|
|
|
au BufWinLeave *.c mkview
|
2017-04-20 04:01:11 -07:00
|
|
|
au BufWinEnter *.c silent! loadview
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
==============================================================================
|
2020-08-31 00:51:35 -07:00
|
|
|
Shada ("shared data") file *shada* *shada-file*
|
2015-10-08 11:11:38 -07:00
|
|
|
|
2014-07-10 21:05:51 -07:00
|
|
|
If you exit Vim and later start it again, you would normally lose a lot of
|
2015-07-05 04:08:50 -07:00
|
|
|
information. The ShaDa file can be used to remember that information, which
|
2021-09-06 10:35:34 -07:00
|
|
|
enables you to continue where you left off. Its name is the abbreviation of
|
2023-06-22 03:44:51 -07:00
|
|
|
SHAred DAta because it is used for sharing data between Nvim sessions.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
This is introduced in section |21.3| of the user manual.
|
|
|
|
|
2015-07-05 04:08:50 -07:00
|
|
|
The ShaDa file is used to store:
|
2014-07-10 21:05:51 -07:00
|
|
|
- The command line history.
|
|
|
|
- The search string history.
|
|
|
|
- The input-line history.
|
|
|
|
- Contents of non-empty registers.
|
|
|
|
- Marks for several files.
|
|
|
|
- File marks, pointing to locations in files.
|
|
|
|
- Last search/substitute pattern (for 'n' and '&').
|
|
|
|
- The buffer list.
|
|
|
|
- Global variables.
|
|
|
|
|
2015-07-05 04:08:50 -07:00
|
|
|
You could also use a Session file. The difference is that the ShaDa file
|
2014-07-10 21:05:51 -07:00
|
|
|
does not depend on what you are working on. There normally is only one
|
2015-07-05 04:08:50 -07:00
|
|
|
ShaDa file. Session files are used to save the state of a specific editing
|
2014-07-10 21:05:51 -07:00
|
|
|
Session. You could have several Session files, one for each project you are
|
2015-07-05 04:08:50 -07:00
|
|
|
working on. ShaDa and Session files together can be used to effectively
|
2014-07-10 21:05:51 -07:00
|
|
|
enter Vim and directly start working in your desired setup. |session-file|
|
|
|
|
|
2015-07-05 04:08:50 -07:00
|
|
|
*shada-read*
|
2015-07-05 16:26:44 -07:00
|
|
|
When Vim is started and the 'shada' option is non-empty, the contents of
|
2015-07-05 04:08:50 -07:00
|
|
|
the ShaDa file are read and the info can be used in the appropriate places.
|
2014-07-10 21:05:51 -07:00
|
|
|
The |v:oldfiles| variable is filled. The marks are not read in at startup
|
2015-07-05 16:26:44 -07:00
|
|
|
(but file marks are). See |initialization| for how to set the 'shada'
|
2014-07-10 21:05:51 -07:00
|
|
|
option upon startup.
|
|
|
|
|
2015-07-05 04:08:50 -07:00
|
|
|
*shada-write*
|
2021-09-06 10:35:34 -07:00
|
|
|
When Vim exits and 'shada' is non-empty, the info is stored in the ShaDa file
|
|
|
|
(it's actually merged with the existing one, if one exists |shada-merging|).
|
|
|
|
The 'shada' option is a string containing information about what info should
|
2015-07-18 11:58:44 -07:00
|
|
|
be stored, and contains limits on how much should be stored (see 'shada').
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
Notes for Unix:
|
2015-07-05 04:08:50 -07:00
|
|
|
- The file protection for the ShaDa file will be set to prevent other users
|
2014-07-10 21:05:51 -07:00
|
|
|
from being able to read it, because it may contain any text or commands that
|
|
|
|
you have worked with.
|
2015-07-05 04:08:50 -07:00
|
|
|
- If you want to share the ShaDa file with other users (e.g. when you "su"
|
2014-07-10 21:05:51 -07:00
|
|
|
to another user), you can make the file writable for the group or everybody.
|
2015-07-05 04:08:50 -07:00
|
|
|
Vim will preserve this when writing new ShaDa files. Be careful, don't
|
|
|
|
allow just anybody to read and write your ShaDa file!
|
|
|
|
- Vim will not overwrite a ShaDa file that is not writable by the current
|
2014-07-10 21:05:51 -07:00
|
|
|
"real" user. This helps for when you did "su" to become root, but your
|
2024-03-18 15:55:30 -07:00
|
|
|
$HOME is still set to a normal user's home directory. Otherwise, Vim would
|
2015-07-05 04:08:50 -07:00
|
|
|
create a ShaDa file owned by root that nobody else can read.
|
|
|
|
- The ShaDa file cannot be a symbolic link. This is to avoid security
|
2014-07-10 21:05:51 -07:00
|
|
|
issues.
|
|
|
|
|
2015-07-05 16:26:44 -07:00
|
|
|
Marks are stored for each file separately. When a file is read and 'shada'
|
2015-07-05 04:08:50 -07:00
|
|
|
is non-empty, the marks for that file are read from the ShaDa file. NOTE:
|
2014-07-10 21:05:51 -07:00
|
|
|
The marks are only written when exiting Vim, which is fine because marks are
|
|
|
|
remembered for all the files you have opened in the current editing session,
|
|
|
|
unless ":bdel" is used. If you want to save the marks for a file that you are
|
2015-07-05 16:26:44 -07:00
|
|
|
about to abandon with ":bdel", use ":wsh". The '[' and ']' marks are not
|
2014-07-10 21:05:51 -07:00
|
|
|
stored, but the '"' mark is. The '"' mark is very useful for jumping to the
|
|
|
|
cursor position when the file was last exited. No marks are saved for files
|
2015-07-05 16:26:44 -07:00
|
|
|
that start with any string given with the "r" flag in 'shada'. This can be
|
2021-04-24 20:14:11 -07:00
|
|
|
used to avoid saving marks for files on removable media (for MS-Windows you
|
|
|
|
would use "ra:,rb:").
|
2015-07-05 04:08:50 -07:00
|
|
|
The |v:oldfiles| variable is filled with the file names that the ShaDa file
|
2014-07-10 21:05:51 -07:00
|
|
|
has marks for.
|
|
|
|
|
2015-07-05 04:08:50 -07:00
|
|
|
*shada-file-marks*
|
|
|
|
Uppercase marks ('A to 'Z) are stored when writing the ShaDa file. The
|
|
|
|
numbered marks ('0 to '9) are a bit special. When the ShaDa file is written
|
2015-07-05 16:26:44 -07:00
|
|
|
(when exiting or with the |:wshada| command), '0 is set to the current cursor
|
2014-07-10 21:05:51 -07:00
|
|
|
position and file. The old '0 is moved to '1, '1 to '2, etc. This
|
|
|
|
resembles what happens with the "1 to "9 delete registers. If the current
|
|
|
|
cursor position is already present in '0 to '9, it is moved to '0, to avoid
|
|
|
|
having the same position twice. The result is that with "'0", you can jump
|
|
|
|
back to the file and line where you exited Vim. To do that right away, try
|
|
|
|
using this command: >
|
|
|
|
|
|
|
|
vim -c "normal '0"
|
|
|
|
|
2024-03-18 15:55:30 -07:00
|
|
|
In a C shell descendant, you could make an alias for it: >
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
alias lvim vim -c '"'normal "'"0'"'
|
|
|
|
|
2024-03-18 15:55:30 -07:00
|
|
|
For a Bash-like shell: >
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
alias lvim='vim -c "normal '\''0"'
|
|
|
|
|
2015-07-05 16:26:44 -07:00
|
|
|
Use the "r" flag in 'shada' to specify for which files no marks should be
|
2014-07-10 21:05:51 -07:00
|
|
|
remembered.
|
|
|
|
|
2015-07-26 11:02:56 -07:00
|
|
|
MERGING *shada-merging*
|
2018-12-08 18:10:54 -07:00
|
|
|
|
2021-09-06 10:35:34 -07:00
|
|
|
When writing ShaDa files with |:wshada| without bang or at regular exit
|
|
|
|
information in the existing ShaDa file is merged with information from current
|
2023-06-22 03:44:51 -07:00
|
|
|
Nvim instance. For this purpose ShaDa files store timestamps associated
|
2015-07-18 11:58:44 -07:00
|
|
|
with ShaDa entries. Specifically the following is being done:
|
|
|
|
|
2021-09-06 10:35:34 -07:00
|
|
|
1. History lines are merged, ordered by timestamp. Maximum amount of items in
|
|
|
|
ShaDa file is defined by 'shada' option (|shada-/|, |shada-:|, |shada-@|,
|
|
|
|
etc: one suboption for each character that represents history name
|
2015-07-18 11:58:44 -07:00
|
|
|
(|:history|)).
|
2023-06-22 03:44:51 -07:00
|
|
|
2. Local marks and changes for files that were not opened by Nvim are copied
|
|
|
|
to new ShaDa file. Marks for files that were opened by Nvim are merged,
|
|
|
|
changes to files opened by Nvim are ignored. |shada-'|
|
2021-09-06 10:35:34 -07:00
|
|
|
3. Jump list is merged: jumps are ordered by timestamp, identical jumps
|
2015-07-18 11:58:44 -07:00
|
|
|
(identical position AND timestamp) are squashed.
|
2021-09-06 10:35:34 -07:00
|
|
|
4. Search patterns and substitute strings are not merged: search pattern or
|
|
|
|
substitute string which has greatest timestamp will be the only one copied
|
2015-07-18 11:58:44 -07:00
|
|
|
to ShaDa file.
|
2021-09-06 10:35:34 -07:00
|
|
|
5. For each register entity with greatest timestamp is the only saved.
|
2015-07-18 11:58:44 -07:00
|
|
|
|shada-<|
|
2023-06-22 03:44:51 -07:00
|
|
|
6. All saved variables are saved from current Nvim instance. Additionally
|
2021-09-06 10:35:34 -07:00
|
|
|
existing variable values are copied, meaning that the only way to remove
|
|
|
|
variable from a ShaDa file is either removing it by hand or disabling
|
2015-07-18 11:58:44 -07:00
|
|
|
writing variables completely. |shada-!|
|
|
|
|
7. For each global mark entity with greatest timestamp is the only saved.
|
2021-09-06 10:35:34 -07:00
|
|
|
8. Buffer list and header are the only entries which are not merged in any
|
|
|
|
fashion: the only header and buffer list present are the ones from the
|
2023-06-22 03:44:51 -07:00
|
|
|
Nvim instance which was last writing the file. |shada-%|
|
2015-07-18 11:58:44 -07:00
|
|
|
|
2015-07-26 11:02:56 -07:00
|
|
|
COMPATIBILITY *shada-compatibility*
|
2018-12-08 18:10:54 -07:00
|
|
|
|
2015-07-26 11:02:56 -07:00
|
|
|
ShaDa files are forward and backward compatible. This means that
|
|
|
|
|
2021-09-06 10:35:34 -07:00
|
|
|
1. Entries which have unknown type (i.e. that hold unidentified data) are
|
2015-07-26 11:02:56 -07:00
|
|
|
ignored when reading and blindly copied when writing.
|
2021-09-06 10:35:34 -07:00
|
|
|
2. Register entries with unknown register name are ignored when reading and
|
|
|
|
blindly copied when writing. Limitation: only registers that use name with
|
2015-08-04 21:17:48 -07:00
|
|
|
code in interval [1, 255] are supported. |registers|
|
2021-09-06 10:35:34 -07:00
|
|
|
3. Register entries with unknown register type are ignored when reading and
|
2015-07-26 11:02:56 -07:00
|
|
|
merged as usual when writing. |getregtype()|
|
2021-09-06 10:35:34 -07:00
|
|
|
4. Local and global mark entries with unknown mark names are ignored when
|
|
|
|
reading. When writing global mark entries are blindly copied and local mark
|
|
|
|
entries are also blindly copied, but only if file they are attached to fits
|
|
|
|
in the |shada-'| limit. Unknown local mark entry's timestamp is also taken
|
|
|
|
into account when calculating which files exactly should fit into this
|
|
|
|
limit. Limitation: only marks that use name with code in interval [1, 255]
|
2015-08-04 21:17:48 -07:00
|
|
|
are supported. |mark-motions|
|
2021-09-06 10:35:34 -07:00
|
|
|
5. History entries with unknown history type are ignored when reading and
|
|
|
|
blindly copied when writing. Limitation: there can be only up to 256
|
2015-08-04 21:17:48 -07:00
|
|
|
history types. |history|
|
2021-09-06 10:35:34 -07:00
|
|
|
6. Unknown keys found in register, local mark, global mark, change, jump and
|
|
|
|
search pattern entries are saved internally and dumped when writing.
|
2023-06-22 03:44:51 -07:00
|
|
|
Entries created during Nvim session never have such additions.
|
2021-09-06 10:35:34 -07:00
|
|
|
7. Additional elements found in replacement string and history entries are
|
2023-06-22 03:44:51 -07:00
|
|
|
saved internally and dumped. Entries created during Nvim session never
|
2015-07-26 11:02:56 -07:00
|
|
|
have such additions.
|
2021-09-06 10:35:34 -07:00
|
|
|
8. Additional elements found in variable entries are simply ignored when
|
|
|
|
reading. When writing new variables they will be preserved during merging,
|
2023-06-22 03:44:51 -07:00
|
|
|
but that's all. Variable values dumped from current Nvim session never
|
2021-09-06 10:35:34 -07:00
|
|
|
have additional elements, even if variables themselves were obtained by
|
2015-07-26 11:02:56 -07:00
|
|
|
reading ShaDa files.
|
|
|
|
|
2021-09-06 10:35:34 -07:00
|
|
|
"Blindly" here means that there will be no attempts to somehow merge them,
|
2015-07-26 11:02:56 -07:00
|
|
|
even if other entries (with known name/type/etc) are merged. |shada-merging|
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2015-07-05 04:08:50 -07:00
|
|
|
SHADA FILE NAME *shada-file-name*
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2019-04-16 12:33:40 -07:00
|
|
|
- Default name of the |shada| file is:
|
2021-09-06 10:35:34 -07:00
|
|
|
Unix: "$XDG_STATE_HOME/nvim/shada/main.shada"
|
|
|
|
Windows: "$XDG_STATE_HOME/nvim-data/shada/main.shada"
|
2019-04-16 12:33:40 -07:00
|
|
|
See also |base-directories|.
|
|
|
|
- To choose a different file name you can use:
|
|
|
|
- The "n" flag in the 'shada' option.
|
|
|
|
- The |-i| startup argument. "NONE" means no shada file is ever read or
|
|
|
|
written. Also not for the commands below!
|
|
|
|
- The 'shadafile' option. The value from the "-i" argument (if any) is
|
|
|
|
stored in the 'shadafile' option.
|
2014-07-10 21:05:51 -07:00
|
|
|
- For the commands below, another file name can be given, overriding the
|
2015-07-05 16:26:44 -07:00
|
|
|
default and the name given with 'shada' or "-i" (unless it's NONE).
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
|
2015-07-05 04:08:50 -07:00
|
|
|
MANUALLY READING AND WRITING *shada-read-write*
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2015-07-05 04:08:50 -07:00
|
|
|
Two commands can be used to read and write the ShaDa file manually. This
|
2014-07-10 21:05:51 -07:00
|
|
|
can be used to exchange registers between two running Vim programs: First
|
2015-07-05 16:26:44 -07:00
|
|
|
type ":wsh" in one and then ":rsh" in the other. Note that if the register
|
2024-03-18 15:55:30 -07:00
|
|
|
already contained something, then ":rsh!" would be required. Also note,
|
|
|
|
however, that this means everything will be overwritten with information from
|
2014-07-10 21:05:51 -07:00
|
|
|
the first Vim, including the command line history, etc.
|
|
|
|
|
2015-07-05 04:08:50 -07:00
|
|
|
The ShaDa file itself can be edited by hand too, although we suggest you
|
2021-09-06 10:35:34 -07:00
|
|
|
start with an existing one to get the format right. You need to understand
|
|
|
|
MessagePack (or, more likely, find software that is able to use it) format to
|
|
|
|
do this. This can be useful in order to create a second file, say
|
2024-03-18 15:55:30 -07:00
|
|
|
"~/.my.shada", which could contain certain settings that you always want when
|
2023-06-22 03:44:51 -07:00
|
|
|
you first start Nvim. For example, you can preload registers with
|
2021-09-06 10:35:34 -07:00
|
|
|
particular data, or put certain commands in the command line history. A line
|
2020-07-19 12:42:02 -07:00
|
|
|
in your |config| file like >
|
2015-07-05 16:26:44 -07:00
|
|
|
:rshada! ~/.my.shada
|
2021-09-06 10:35:34 -07:00
|
|
|
can be used to load this information. You could even have different ShaDa
|
|
|
|
files for different types of files (e.g., C code) and load them based on the
|
|
|
|
file name, using the ":autocmd" command (see |:autocmd|). More information on
|
2015-08-07 18:52:42 -07:00
|
|
|
ShaDa file format is contained in |shada-format| section.
|
2015-07-05 04:08:50 -07:00
|
|
|
|
2017-01-02 12:09:48 -07:00
|
|
|
*E136* *E929* *shada-error-handling*
|
2023-06-22 03:44:51 -07:00
|
|
|
Some errors make Nvim leave temporary file named `{basename}.tmp.X` (X is
|
2021-09-06 10:35:34 -07:00
|
|
|
any free letter from `a` to `z`) while normally it will create this file,
|
|
|
|
write to it and then rename `{basename}.tmp.X` to `{basename}`. Such errors
|
2015-08-23 07:59:18 -07:00
|
|
|
include:
|
|
|
|
|
2023-10-11 02:58:07 -07:00
|
|
|
- Errors which make Nvim think that the file being read is not a ShaDa
|
|
|
|
file at all:
|
2021-09-06 10:35:34 -07:00
|
|
|
non-ShaDa files are not overwritten for safety reasons to avoid accidentally
|
|
|
|
destroying an unrelated file. This could happen e.g. when typing "nvim -i
|
|
|
|
file" in place of "nvim -R file" (yes, somebody did that at least with Vim).
|
2015-08-23 07:59:18 -07:00
|
|
|
Such errors are listed at |shada-critical-contents-errors|.
|
2021-09-06 10:35:34 -07:00
|
|
|
- If writing to the temporary file failed: e.g. because of the insufficient
|
2015-08-23 07:59:18 -07:00
|
|
|
space left.
|
2015-08-23 08:10:40 -07:00
|
|
|
- If renaming file failed: e.g. because of insufficient permissions.
|
2023-06-22 03:44:51 -07:00
|
|
|
- If target ShaDa file has different from the Nvim instance's owners (user
|
2021-09-06 10:35:34 -07:00
|
|
|
and group) and changing them failed. Unix-specific, applies only when
|
2023-06-22 03:44:51 -07:00
|
|
|
Nvim was launched from root.
|
2015-08-23 07:59:18 -07:00
|
|
|
|
2021-09-06 10:35:34 -07:00
|
|
|
Do not forget to remove the temporary file or replace the target file with
|
|
|
|
temporary one after getting one of the above errors or all attempts to create
|
|
|
|
a ShaDa file may fail with |E929|. If you got one of them when using
|
2023-06-22 03:44:51 -07:00
|
|
|
|:wshada| (and not when exiting Nvim: i.e. when you have Nvim session
|
2015-08-23 07:59:18 -07:00
|
|
|
running) you have additional options:
|
|
|
|
|
2021-09-06 10:35:34 -07:00
|
|
|
- First thing which you should consider if you got any error, except failure
|
|
|
|
to write to the temporary file: remove existing file and replace it with the
|
2023-06-22 03:44:51 -07:00
|
|
|
temporary file. Do it even if you have running Nvim instance.
|
2021-09-06 10:35:34 -07:00
|
|
|
- Fix the permissions and/or file ownership, free some space and attempt to
|
2015-08-23 07:59:18 -07:00
|
|
|
write again. Do not remove the existing file.
|
2021-09-06 10:35:34 -07:00
|
|
|
- Use |:wshada| with bang. Does not help in case of permission error. If
|
|
|
|
target file was actually the ShaDa file some information may be lost in this
|
|
|
|
case. To make the matters slightly better use |:rshada| prior to writing,
|
|
|
|
but this still will loose buffer-local marks and change list entries for any
|
2023-06-22 03:44:51 -07:00
|
|
|
file which is not opened in the current Nvim instance.
|
2021-09-06 10:35:34 -07:00
|
|
|
- Remove the target file from shell and use |:wshada|. Consequences are not
|
|
|
|
different from using |:wshada| with bang, but "rm -f" works in some cases
|
2015-08-23 07:59:18 -07:00
|
|
|
when you don't have write permissions.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2015-07-25 09:42:04 -07:00
|
|
|
*:rsh* *:rshada* *E886*
|
2015-07-05 16:26:44 -07:00
|
|
|
:rsh[ada][!] [file] Read from ShaDa file [file] (default: see above).
|
2014-07-10 21:05:51 -07:00
|
|
|
If [!] is given, then any information that is
|
|
|
|
already set (registers, marks, |v:oldfiles|, etc.)
|
2015-04-29 17:04:26 -07:00
|
|
|
will be overwritten.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2015-08-01 16:49:44 -07:00
|
|
|
*:wsh* *:wshada* *E137*
|
2015-07-05 16:26:44 -07:00
|
|
|
:wsh[ada][!] [file] Write to ShaDa file [file] (default: see above).
|
2014-07-10 21:05:51 -07:00
|
|
|
The information in the file is first read in to make
|
|
|
|
a merge between old and new info. When [!] is used,
|
|
|
|
the old information is not read first, only the
|
2021-09-06 10:35:34 -07:00
|
|
|
internal info is written (also disables safety checks
|
|
|
|
described in |shada-error-handling|). If 'shada' is
|
2015-08-23 07:59:18 -07:00
|
|
|
empty, marks for up to 100 files will be written.
|
2021-09-06 10:35:34 -07:00
|
|
|
When you get error "E929: All .tmp.X files exist,
|
2024-03-18 15:55:30 -07:00
|
|
|
cannot write ShaDa file!", check that no old temp
|
|
|
|
files were left behind (e.g.
|
2021-09-06 10:35:34 -07:00
|
|
|
~/.local/state/nvim/shada/main.shada.tmp*).
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2015-10-23 03:58:02 -07:00
|
|
|
Note: Executing :wshada will reset all |'quote| marks.
|
|
|
|
|
2015-10-30 11:35:12 -07:00
|
|
|
*:o* *:ol* *:oldfiles*
|
2016-08-11 06:35:17 -07:00
|
|
|
:o[ldfiles] List the files that have marks stored in the ShaDa
|
2014-07-10 21:05:51 -07:00
|
|
|
file. This list is read on startup and only changes
|
2017-04-28 18:04:17 -07:00
|
|
|
afterwards with `:rshada!`. Also see |v:oldfiles|.
|
2014-07-10 21:05:51 -07:00
|
|
|
The number can be used with |c_#<|.
|
2017-04-28 11:42:06 -07:00
|
|
|
The output can be filtered with |:filter|, e.g.: >
|
|
|
|
filter /\.vim/ oldfiles
|
|
|
|
< The filtering happens on the file name.
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2015-10-30 11:35:12 -07:00
|
|
|
:bro[wse] o[ldfiles][!]
|
2014-07-10 21:05:51 -07:00
|
|
|
List file names as with |:oldfiles|, and then prompt
|
|
|
|
for a number. When the number is valid that file from
|
|
|
|
the list is edited.
|
|
|
|
If you get the |press-enter| prompt you can press "q"
|
|
|
|
and still get the prompt to enter a file number.
|
2024-03-18 15:55:30 -07:00
|
|
|
Use [!] to abandon a modified buffer. |abandon|
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2015-08-07 18:52:42 -07:00
|
|
|
SHADA FILE FORMAT *shada-format*
|
|
|
|
|
2021-09-06 10:35:34 -07:00
|
|
|
ShaDa files are concats of MessagePack entries. Each entry is a concat of
|
2015-08-07 18:52:42 -07:00
|
|
|
exactly four MessagePack objects:
|
|
|
|
|
2021-09-06 10:35:34 -07:00
|
|
|
1. First goes type of the entry. Object type must be an unsigned integer.
|
2015-08-07 18:52:42 -07:00
|
|
|
Object type must not be equal to zero.
|
|
|
|
2. Second goes entry timestamp. It must also be an unsigned integer.
|
2021-09-06 10:35:34 -07:00
|
|
|
3. Third goes the length of the fourth entry. Unsigned integer as well, used
|
2015-08-07 18:52:42 -07:00
|
|
|
for fast skipping without parsing.
|
2021-09-06 10:35:34 -07:00
|
|
|
4. Fourth is actual entry data. All currently used ShaDa entries use
|
|
|
|
containers to hold data: either map or array. All string values in those
|
|
|
|
containers are either binary (applies to filenames) or UTF-8, yet parser
|
2017-04-08 09:34:01 -07:00
|
|
|
needs to expect that invalid bytes may be present in a UTF-8 string.
|
|
|
|
|
|
|
|
Exact format depends on the entry type:
|
2015-08-07 18:52:42 -07:00
|
|
|
|
|
|
|
Entry type (name) Entry data ~
|
2021-09-06 10:35:34 -07:00
|
|
|
1 (Header) Map containing data that describes the generator
|
|
|
|
instance that wrote this ShaDa file. It is ignored
|
2015-08-18 09:32:31 -07:00
|
|
|
when reading ShaDa files. Contains the following data:
|
2015-08-07 18:52:42 -07:00
|
|
|
Key Data ~
|
2021-09-06 10:35:34 -07:00
|
|
|
generator Binary, software used to generate ShaDa
|
|
|
|
file. Is equal to "nvim" when ShaDa file was
|
2023-06-22 03:44:51 -07:00
|
|
|
written by Nvim.
|
2015-08-18 09:32:31 -07:00
|
|
|
version Binary, generator version.
|
2015-08-07 18:52:42 -07:00
|
|
|
encoding Binary, effective 'encoding' value.
|
|
|
|
max_kbyte Integer, effective |shada-s| limit value.
|
|
|
|
pid Integer, instance process ID.
|
2022-10-06 06:16:00 -07:00
|
|
|
`*` It is allowed to have any number of
|
2015-08-18 09:32:31 -07:00
|
|
|
additional keys with any data.
|
2021-09-06 10:35:34 -07:00
|
|
|
2 (SearchPattern) Map containing data describing last used search or
|
|
|
|
substitute pattern. Normally ShaDa file contains two
|
|
|
|
such entries: one with "ss" key set to true (describes
|
|
|
|
substitute pattern, see |:substitute|), and one set to
|
|
|
|
false (describes search pattern, see
|
|
|
|
|search-commands|). "su" key should be true on one of
|
|
|
|
the entries. If key value is equal to default then it
|
2015-08-07 18:52:42 -07:00
|
|
|
is normally not present. Keys:
|
|
|
|
Key Type Default Description ~
|
|
|
|
sm Boolean true Effective 'magic' value.
|
|
|
|
sc Boolean false Effective 'smartcase' value.
|
2021-09-06 10:35:34 -07:00
|
|
|
sl Boolean true True if search pattern comes
|
|
|
|
with a line offset. See
|
2015-08-07 18:52:42 -07:00
|
|
|
|search-offset|.
|
2021-09-06 10:35:34 -07:00
|
|
|
se Boolean false True if |search-offset|
|
|
|
|
requested to place cursor at
|
|
|
|
(relative to) the end of the
|
2015-08-07 18:52:42 -07:00
|
|
|
pattern.
|
|
|
|
so Integer 0 Offset value. |search-offset|
|
2021-09-06 10:35:34 -07:00
|
|
|
su Boolean false True if current entry was the
|
2015-08-07 18:52:42 -07:00
|
|
|
last used search pattern.
|
2021-09-06 10:35:34 -07:00
|
|
|
ss Boolean false True if current entry describes
|
2015-08-07 18:52:42 -07:00
|
|
|
|:substitute| pattern.
|
|
|
|
sh Boolean false True if |v:hlsearch| is on.
|
2021-09-06 10:35:34 -07:00
|
|
|
With |shada-h| or 'nohlsearch'
|
2015-08-07 18:52:42 -07:00
|
|
|
this key is always false.
|
|
|
|
sp Binary N/A Actual pattern. Required.
|
2021-09-06 10:35:34 -07:00
|
|
|
sb Boolean false True if search direction is
|
2015-11-01 11:26:53 -07:00
|
|
|
backward.
|
2022-10-06 06:16:00 -07:00
|
|
|
`*` any none Other keys are allowed for
|
2021-09-06 10:35:34 -07:00
|
|
|
compatibility reasons, see
|
2015-08-07 18:52:42 -07:00
|
|
|
|shada-compatibility|.
|
2021-09-06 10:35:34 -07:00
|
|
|
3 (SubString) Array containing last |:substitute| replacement string.
|
|
|
|
Contains single entry: binary, replacement string used.
|
|
|
|
More entries are allowed for compatibility reasons, see
|
2015-08-07 18:52:42 -07:00
|
|
|
|shada-compatibility|.
|
2021-09-06 10:35:34 -07:00
|
|
|
4 (HistoryEntry) Array containing one entry from history. Should have
|
|
|
|
two or three entries. First one is history type
|
|
|
|
(unsigned integer), second is history line (binary),
|
|
|
|
third is the separator character (unsigned integer,
|
|
|
|
must be in interval [0, 255]). Third item is only
|
|
|
|
valid for search history. Possible history types are
|
|
|
|
listed in |hist-names|, here are the corresponding
|
|
|
|
numbers: 0 - cmd, 1 - search, 2 - expr, 3 - input,
|
2015-08-07 18:52:42 -07:00
|
|
|
4 - debug.
|
2021-09-06 10:35:34 -07:00
|
|
|
5 (Register) Map describing one register (|registers|). If key
|
|
|
|
value is equal to default then it is normally not
|
2015-08-07 18:52:42 -07:00
|
|
|
present. Keys:
|
2016-05-04 11:12:50 -07:00
|
|
|
Key Type Def Description ~
|
|
|
|
rt UInteger 0 Register type:
|
|
|
|
No Description ~
|
2019-11-25 02:08:02 -07:00
|
|
|
0 |charwise-register|
|
2016-05-04 11:12:50 -07:00
|
|
|
1 |linewise-register|
|
|
|
|
2 |blockwise-register|
|
|
|
|
rw UInteger 0 Register width. Only valid
|
|
|
|
for |blockwise-register|s.
|
|
|
|
rc Array of binary N/A Register contents. Each
|
|
|
|
entry in the array
|
|
|
|
represents its own line.
|
|
|
|
NUL characters inside the
|
|
|
|
line should be represented
|
|
|
|
as NL according to
|
|
|
|
|NL-used-for-Nul|.
|
|
|
|
ru Boolean false Unnamed register. Whether
|
|
|
|
the unnamed register had
|
|
|
|
pointed to this register.
|
|
|
|
n UInteger N/A Register name: character
|
|
|
|
code in range [1, 255].
|
|
|
|
Example: |quote0| register
|
|
|
|
has name 48 (ASCII code for
|
|
|
|
zero character).
|
|
|
|
* any none Other keys are allowed
|
|
|
|
for compatibility reasons,
|
|
|
|
see |shada-compatibility|.
|
2021-09-06 10:35:34 -07:00
|
|
|
6 (Variable) Array containing two items: variable name (binary) and
|
|
|
|
variable value (any object). Values are converted
|
|
|
|
using the same code |msgpackparse()| uses when reading,
|
|
|
|
|msgpackdump()| when writing, so there may appear
|
|
|
|
|msgpack-special-dict|s. If there are more then two
|
|
|
|
entries then the rest are ignored
|
2015-08-07 18:52:42 -07:00
|
|
|
(|shada-compatibility|).
|
|
|
|
7 (GlobalMark)
|
|
|
|
8 (Jump)
|
|
|
|
10 (LocalMark)
|
|
|
|
11 (Change) Map containing some position description:
|
|
|
|
Entry Position ~
|
2023-10-29 01:02:32 -07:00
|
|
|
GlobalMark Global mark position. |'A|
|
2015-08-07 18:52:42 -07:00
|
|
|
LocalMark Local mark position. |'a|
|
|
|
|
Jump One position from the |jumplist|.
|
|
|
|
Change One position from the |changelist|.
|
|
|
|
|
|
|
|
Data contained in the map:
|
|
|
|
Key Type Default Description ~
|
2021-09-06 10:35:34 -07:00
|
|
|
l UInteger 1 Position line number. Must be
|
2015-08-07 18:52:42 -07:00
|
|
|
greater then zero.
|
|
|
|
c UInteger 0 Position column number.
|
2021-09-06 10:35:34 -07:00
|
|
|
n UInteger 34 ('"') Mark name. Only valid for
|
|
|
|
GlobalMark and LocalMark
|
2015-08-07 18:52:42 -07:00
|
|
|
entries.
|
|
|
|
f Binary N/A File name. Required.
|
2022-10-06 06:16:00 -07:00
|
|
|
`*` any none Other keys are allowed for
|
2021-09-06 10:35:34 -07:00
|
|
|
compatibility reasons, see
|
2015-08-07 18:52:42 -07:00
|
|
|
|shada-compatibility|.
|
2021-09-06 10:35:34 -07:00
|
|
|
9 (BufferList) Array containing maps. Each map in the array
|
2015-08-07 18:52:42 -07:00
|
|
|
represents one buffer. Possible keys:
|
|
|
|
Key Type Default Description ~
|
2021-09-06 10:35:34 -07:00
|
|
|
l UInteger 1 Position line number. Must be
|
2015-08-07 18:52:42 -07:00
|
|
|
greater then zero.
|
|
|
|
c UInteger 0 Position column number.
|
|
|
|
f Binary N/A File name. Required.
|
2022-10-06 06:16:00 -07:00
|
|
|
`*` any none Other keys are allowed for
|
2021-09-06 10:35:34 -07:00
|
|
|
compatibility reasons, see
|
2015-08-07 18:52:42 -07:00
|
|
|
|shada-compatibility|.
|
2022-10-06 06:16:00 -07:00
|
|
|
`*` (Unknown) Any other entry type is allowed for compatibility
|
2015-08-07 18:52:42 -07:00
|
|
|
reasons, see |shada-compatibility|.
|
|
|
|
|
|
|
|
*E575* *E576*
|
2023-10-11 02:58:07 -07:00
|
|
|
Errors in ShaDa file may have two types:
|
|
|
|
1. E575 for “logical” errors.
|
|
|
|
2. E576 for “critical” errors.
|
|
|
|
When writing, critical errors trigger behaviour described in
|
|
|
|
|shada-error-handling|.
|
|
|
|
When reading, critical errors cause the rest of the file to be skipped.
|
|
|
|
Critical errors include:
|
2015-08-23 07:59:18 -07:00
|
|
|
*shada-critical-contents-errors*
|
2015-08-07 18:52:42 -07:00
|
|
|
- Any of first three MessagePack objects being not an unsigned integer.
|
2021-09-06 10:35:34 -07:00
|
|
|
- Third object requesting amount of bytes greater then bytes left in the ShaDa
|
2015-08-07 18:52:42 -07:00
|
|
|
file.
|
|
|
|
- Entry with zero type. I.e. first object being equal to zero.
|
|
|
|
- MessagePack parser failing to parse the entry data.
|
2021-09-06 10:35:34 -07:00
|
|
|
- MessagePack parser consuming less or requesting greater bytes then described
|
|
|
|
in the third object for parsing fourth object. I.e. when fourth object
|
|
|
|
either contains more then one MessagePack object or it does not contain
|
2015-08-07 18:52:42 -07:00
|
|
|
complete MessagePack object.
|
|
|
|
|
2016-07-28 21:41:21 -07:00
|
|
|
==============================================================================
|
2020-08-31 00:51:35 -07:00
|
|
|
Standard Paths *standard-path*
|
2016-07-28 21:41:21 -07:00
|
|
|
|
2021-09-06 10:35:34 -07:00
|
|
|
Nvim stores configuration, data, and logs in standard locations. Plugins are
|
|
|
|
strongly encouraged to follow this pattern also. Use |stdpath()| to get the
|
2021-01-16 13:14:59 -07:00
|
|
|
paths.
|
2016-07-28 21:41:21 -07:00
|
|
|
|
2017-12-27 11:30:23 -07:00
|
|
|
*base-directories* *xdg*
|
2017-06-06 06:02:51 -07:00
|
|
|
The "base" (root) directories conform to the XDG Base Directory Specification.
|
|
|
|
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
2023-09-20 02:04:30 -07:00
|
|
|
The $XDG_CONFIG_HOME, $XDG_DATA_HOME, $XDG_RUNTIME_DIR, $XDG_STATE_HOME,
|
|
|
|
$XDG_CACHE_HOME, $XDG_CONFIG_DIRS and $XDG_DATA_DIRS environment variables
|
|
|
|
are used if defined, else default values (listed below) are used.
|
2017-06-06 06:02:51 -07:00
|
|
|
|
2023-09-27 10:09:55 -07:00
|
|
|
Throughout the help pages these defaults are used as placeholders, e.g.
|
|
|
|
"~/.config" is understood to mean "$XDG_CONFIG_HOME or ~/.config".
|
|
|
|
|
2018-08-04 18:17:08 -07:00
|
|
|
CONFIG DIRECTORY (DEFAULT) ~
|
|
|
|
*$XDG_CONFIG_HOME* Nvim: stdpath("config")
|
|
|
|
Unix: ~/.config ~/.config/nvim
|
|
|
|
Windows: ~/AppData/Local ~/AppData/Local/nvim
|
2017-06-06 06:02:51 -07:00
|
|
|
|
2018-08-04 18:17:08 -07:00
|
|
|
DATA DIRECTORY (DEFAULT) ~
|
|
|
|
*$XDG_DATA_HOME* Nvim: stdpath("data")
|
|
|
|
Unix: ~/.local/share ~/.local/share/nvim
|
|
|
|
Windows: ~/AppData/Local ~/AppData/Local/nvim-data
|
2017-06-06 06:02:51 -07:00
|
|
|
|
2022-06-30 04:16:46 -07:00
|
|
|
RUN DIRECTORY (DEFAULT) ~
|
|
|
|
*$XDG_RUNTIME_DIR* Nvim: stdpath("run")
|
|
|
|
Unix: /tmp/nvim.user/xxx /tmp/nvim.user/xxx
|
|
|
|
Windows: $TMP/nvim.user/xxx $TMP/nvim.user/xxx
|
|
|
|
|
2021-09-06 10:35:34 -07:00
|
|
|
STATE DIRECTORY (DEFAULT) ~
|
|
|
|
*$XDG_STATE_HOME* Nvim: stdpath("state")
|
|
|
|
Unix: ~/.local/state ~/.local/state/nvim
|
|
|
|
Windows: ~/AppData/Local ~/AppData/Local/nvim-data
|
|
|
|
|
2023-09-20 02:04:30 -07:00
|
|
|
CACHE DIRECTORY (DEFAULT) ~
|
|
|
|
*$XDG_CACHE_HOME* Nvim: stdpath("cache")
|
|
|
|
Unix: ~/.cache ~/.cache/nvim
|
|
|
|
Windows: ~/AppData/Local/Temp ~/AppData/Local/Temp/nvim-data
|
|
|
|
|
|
|
|
LOG FILE (DEFAULT) ~
|
2023-09-27 10:09:55 -07:00
|
|
|
`$NVIM_LOG_FILE` Nvim: stdpath("log")/log
|
2023-09-20 02:04:30 -07:00
|
|
|
Unix: ~/.local/state/nvim ~/.local/state/nvim/log
|
|
|
|
Windows: ~/AppData/Local/nvim-data ~/AppData/Local/nvim-data/log
|
|
|
|
|
2023-09-27 10:09:55 -07:00
|
|
|
Note that stdpath("log") is currently an alias for stdpath("state").
|
|
|
|
|
2023-09-20 02:04:30 -07:00
|
|
|
ADDITIONAL CONFIGS DIRECTORY (DEFAULT) ~
|
|
|
|
*$XDG_CONFIG_DIRS* Nvim: stdpath("config_dirs")
|
|
|
|
Unix: /etc/xdg/ /etc/xdg/nvim
|
|
|
|
Windows: Not applicable Not applicable
|
|
|
|
|
|
|
|
ADDITIONAL DATA DIRECTORY (DEFAULT) ~
|
|
|
|
*$XDG_DATA_DIRS* Nvim: stdpath("data_dirs")
|
|
|
|
Unix: /usr/local/share /usr/local/share/nvim
|
|
|
|
/usr/share /usr/share/nvim
|
|
|
|
Windows: Not applicable Not applicable
|
|
|
|
|
2023-02-16 05:15:02 -07:00
|
|
|
NVIM_APPNAME *$NVIM_APPNAME*
|
2023-06-19 08:40:33 -07:00
|
|
|
The standard directories can be further configured by the `$NVIM_APPNAME`
|
|
|
|
environment variable. This variable controls the sub-directory that Nvim will
|
|
|
|
read from (and auto-create) in each of the base directories. For example,
|
|
|
|
setting `$NVIM_APPNAME` to "foo" before starting will cause Nvim to look for
|
|
|
|
configuration files in `$XDG_CONFIG_HOME/foo` instead of
|
2023-09-27 10:09:55 -07:00
|
|
|
`$XDG_CONFIG_HOME/nvim`. `$NVIM_APPNAME` must be a name, such as "foo", or a
|
|
|
|
relative path, such as "foo/bar".
|
2023-06-19 08:40:33 -07:00
|
|
|
|
|
|
|
One use-case for $NVIM_APPNAME is to "isolate" Nvim applications.
|
|
|
|
Alternatively, for true isolation, on Linux you can use cgroups namespaces: >
|
|
|
|
systemd-run --user -qt -p PrivateUsers=yes -p BindPaths=/home/user/profile_xy:/home/user/.config/nvim nvim
|
|
|
|
|
|
|
|
Note: Throughout the help pages, wherever `$XDG_CONFIG_…/nvim` is mentioned it
|
|
|
|
is understood to mean `$XDG_CONFIG_…/$NVIM_APPNAME`.
|
2023-02-16 05:15:02 -07:00
|
|
|
|
2023-03-09 06:07:36 -07:00
|
|
|
LOG FILE *log* *$NVIM_LOG_FILE* *E5430*
|
2017-12-27 11:30:23 -07:00
|
|
|
Besides 'debug' and 'verbose', Nvim keeps a general log file for internal
|
|
|
|
debugging, plugins and RPC clients. >
|
2017-06-06 06:02:51 -07:00
|
|
|
:echo $NVIM_LOG_FILE
|
2023-09-20 02:04:30 -07:00
|
|
|
By default, the file is located at stdpath("log")/log ($XDG_STATE_HOME/nvim/log)
|
|
|
|
unless that path is inaccessible or if $NVIM_LOG_FILE was set before |startup|.
|
2016-07-28 21:41:21 -07:00
|
|
|
|
2020-08-31 00:51:35 -07:00
|
|
|
|
2018-04-11 13:07:00 -07:00
|
|
|
vim:noet:tw=78:ts=8:ft=help:norl:
|