robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
4836ecad1f
master
1*starting.txt* Nvim 2 3 4 VIM REFERENCE MANUAL by Bram Moolenaar 5 6 7Starting Vim *starting* 8 9 Type |gO| to see the table of contents. 10 11============================================================================== 12Nvim arguments *cli-arguments* 13 14Most often, Nvim is started to edit a single file with the command: > 15 16 nvim filename 17 18More generally, Nvim is started with: > 19 20 nvim [option | filename] .. 21 22Option arguments and file name arguments can be mixed, and any number of them 23can be given. However, watch out for options that take an argument. 24 25The following items decide how to start editing: 26 27 *-file* *---* 28filename One or more file names. The first one will be the current 29 file and read into the buffer. The cursor will be positioned 30 on the first line of the buffer. 31 To avoid a file name starting with a '-' being interpreted as 32 an option, precede the arglist with "--", e.g.: > 33 nvim -- -filename 34< All arguments after "--" are interpreted as file names, no 35 other options or "+command" arguments can follow. 36 37 *--* 38`-` Alias for stdin (standard input). 39 Example: > 40 echo text | nvim - file 41< "text" is read into buffer 1, "file" is opened as buffer 2. 42 In most cases (except -s, -es, |--embed|, --headless) if stdin 43 is not a TTY then it is read as text, so "-" is implied: > 44 echo text | nvim file 45< The buffer will be marked as modified, because it contains 46 text that needs to be saved (except for readonly |-R| mode). 47 If you don't like that, put these lines in your init.vim: > 48 " Don't set 'modified' when reading from stdin 49 au StdinReadPost * set nomodified 50< 51 To read stdin as Normal commands use |-s| with "-": > 52 echo "ifoo" | nvim -s - 53< To read stdin as Ex commands use |-es| or |-e|: > 54 echo "echo getpid()" | nvim -e - -V1 55< To open a file literally named "-", put it after "--": > 56 echo foo | nvim -- - 57< To read stdin as text with |--headless| use "-". 58 59 *-t* *-tag* 60-t {tag} A tag. "tag" is looked up in the tags file, the associated 61 file becomes the current file, and the associated command is 62 executed. Mostly this is used for C programs, in which case 63 "tag" often is a function name. The effect is that the file 64 containing that function becomes the current file and the 65 cursor is positioned on the start of the function (see 66 |tags|). 67 68 *-q* *-qf* 69-q [errorfile] QuickFix mode. The file with the name [errorfile] is read 70 and the first error is displayed. See |quickfix|. 71 If [errorfile] is not given, the 'errorfile' option is used 72 for the file name. See 'errorfile' for the default value. 73 74(nothing) Without one of the four items above, Vim will start editing a 75 new buffer. It's empty and doesn't have a file name. 76 77 *startup-options* 78The option arguments may be given in any order. Single-letter options can be 79combined after one dash. There can be no option arguments after the "--" 80argument. 81 82--help *-h* *--help* *-?* 83-? 84-h Give usage (help) message and exit. 85 86--version *-v* *--version* 87-v Print version information and exit. Same output as for 88 |:version| command. 89 90 *--clean* 91--clean Mimics a fresh install of Nvim: 92 - Skips initializations from files and environment variables. 93 - No 'shada' file is read or written. 94 - Excludes user directories from 'runtimepath' 95 - Loads builtin plugins, unlike "-u NONE -i NONE". 96 97 *--noplugin* 98--noplugin Skip loading plugins. Resets the 'loadplugins' option. 99 Note that the |-u| argument may also disable loading plugins: 100 argument load vimrc files load plugins > 101 (nothing) yes yes 102 -u NONE no no 103 -u NORC no yes 104 --noplugin yes no 105< 106--startuptime {fname} *--startuptime* 107 During startup write timing messages to the file {fname}. 108 This can be used to find out where time is spent while loading 109 your |config|, plugins and opening the first file. 110 When {fname} already exists new messages are appended. 111 112 *-+* 113+[num] The cursor will be positioned on line "num" for the first 114 file being edited. If "num" is missing, the cursor will be 115 positioned on the last line. 116 117 *-+/* 118+/{pat} The cursor will be positioned on the first line containing 119 "pat" in the first file being edited (see |pattern| for the 120 available search patterns). The search starts at the cursor 121 position, which can be the first line or the cursor position 122 last used from |shada|. To force a search from the first 123 line use "+1 +/pat". 124 125+{command} *-+c* *-c* 126-c {command} {command} will be executed after the first file has been 127 read (and after autocommands and modelines for that file have 128 been processed). "command" is interpreted as an Ex command. 129 If the "command" contains spaces, it must be enclosed in 130 double quotes (this depends on the shell that is used). 131 Example: > 132 vim "+set si" main.c 133 vim "+find stdio.h" 134 vim -c "set ff=dos" -c wq mine.mak 135< 136 Note: You can use up to 10 "+" or "-c" arguments in a Vim 137 command. They are executed in the order given. A "-S" 138 argument counts as a "-c" argument as well. 139 140--cmd {command} *--cmd* 141 {command} will be executed before processing any vimrc file. 142 Otherwise, it acts like -c {command}. You can use up to 10 of 143 these commands, independently from "-c" commands. 144 145 *-S* 146-S [file] Executes Vimscript or Lua (".lua") [file] after the first file 147 has been read. See also |:source|. If [file] is not given, 148 defaults to "Session.vim". Equivalent to: > 149 -c "source {file}" 150< Can be repeated like "-c", subject to the same limit of 10 151 "-c" arguments. {file} cannot start with a "-". 152 153-L *-L* *-r* 154-r Recovery mode. Without a file name argument, a list of 155 existing swap files is given. With a file name, a swap file 156 is read to recover a crashed editing session. See 157 |crash-recovery|. 158 159 *-R* 160-R Readonly mode. The 'readonly' option will be set for all the 161 files being edited. You can still edit the buffer, but will 162 be prevented from accidentally overwriting a file. If you 163 forgot that you are in View mode and did make some changes, 164 you can overwrite a file by adding an exclamation mark to 165 the Ex command, as in ":w!". The 'readonly' option can be 166 reset with ":set noro" (see the options chapter, |options|). 167 Subsequent edits will not be done in readonly mode. 168 The 'updatecount' option will be set to 10000, meaning that 169 the swap file will not be updated automatically very often. 170 See |-M| for disallowing modifications. 171 172 *-m* 173-m Modifications not allowed to be written. The 'write' option 174 will be reset, so that writing files is disabled. However, 175 the 'write' option can be set to enable writing again. 176 177 *-M* 178-M Modifications not allowed. The 'modifiable' option will be 179 reset, so that changes are not allowed. The 'write' option 180 will be reset, so that writing files is disabled. However, 181 the 'modifiable' and 'write' options can be set to enable 182 changes and writing. 183 184-e *-e* *-E* 185-E Start Nvim in |Ex-mode|. 186 187 If stdin is not a TTY: 188 • -e reads/executes stdin as Ex commands. 189 • -E reads stdin as text (into buffer 1). 190 191-es *-es* *-Es* *-s-ex* *silent-mode* 192-Es Script mode, aka "silent mode", aka "batch mode". No UI, 193 disables most prompts and messages. Unrelated to |-s|. 194 See also |-S| to run script files. 195 196 -es reads/executes stdin as Ex commands. > 197 printf "put ='foo'\n%%print\n" | nvim -es 198< 199 -Es reads stdin as text (into buffer 1). Use |-c| or "+" to 200 send commands. > 201 printf "foo\n" | nvim -Es +"%print" 202< 203 These commands display on stdout: 204 • :list 205 • :number 206 • :print 207 • :set 208 209 With |:verbose| or 'verbose', other commands display on stderr: > 210 nvim -es +"verbose echo 'foo'" 211 nvim -V1 -es +"echo 'foo'" 212< 213 Commands that wait for typed input (|input()|, |getchar()|, …) 214 stop Nvim on EOF; they do not consume stdin. Lua can read 215 stdin as data: > 216 printf 'lua vim.g.b = io.read()\nfoo\nput =g:b\np' | nvim -es 217< 218 Skips user |config| unless |-u| was given. 219 Disables |shada| unless |-i| was given. 220 Disables swapfile (like |-n|). 221 222 *-l* 223-l {script} [args] 224 Executes Lua {script} non-interactively (no UI) with optional 225 [args] after processing any preceding Nvim |cli-arguments|, 226 then exits. Exits 1 on Lua error. See |-S| to run multiple Lua 227 scripts without args, with a UI. 228 *lua-args* 229 All [args] are treated as {script} arguments and stored in the 230 Lua `_G.arg` global table, thus "-l" ends processing of Nvim 231 arguments. The {script} name is stored at `_G.arg[0]`. 232 233 Sets 'verbose' to 1 (like "-V1"), so Lua `print()` writes to 234 output, as well as other message-emitting functions like 235 |:echo|. 236 If {script} prints messages and doesn't cause Nvim to exit, 237 Nvim ensures output ends with a newline. 238 239 Arguments before "-l" are processed before executing {script}. 240 This example quits before executing "foo.lua": > 241 nvim +q -l foo.lua 242< This loads Lua module "bar" before executing "foo.lua": > 243 nvim +"lua require('bar')" -l foo.lua 244< *lua-shebang* 245 You can set the "shebang" of the script so that Nvim executes 246 the script when called with "./" from a shell (remember to 247 "chmod u+x"): > 248 #!/usr/bin/env -S nvim -l 249< 250 Skips user |config| unless |-u| was given. 251 Disables plugins unless 'loadplugins' was set. 252 Disables |shada| unless |-i| was given. 253 Disables swapfile (like |-n|). 254 255 *-b* 256-b Binary mode. File I/O will only recognize <NL> to separate 257 lines. The 'expandtab' option will be reset. The 'textwidth' 258 option is set to 0. 'modeline' is reset. The 'binary' option 259 is set. This is done after reading the |vimrc| but before 260 reading any file in the arglist. See also |edit-binary|. 261 262 *-A* 263-A Arabic mode. Sets the 'arabic' option on. 264 265 *-H* 266-H Hebrew mode. Sets the 'rightleft' option on and the 'keymap' 267 option to "hebrew". 268 269 *-V* *verbose* 270-V[N] Verbose. Sets the 'verbose' option to [N] (default: 10). 271 Messages will be given for each file that is ":source"d and 272 for reading or writing a ShaDa file. Can be used to find 273 out what is happening upon startup and exit. 274 Example: > 275 nvim -V8 276 277-V[N]{file} 278 Like -V and sets 'verbosefile' to {file} (must not start with 279 a digit). Messages are not displayed, instead they are 280 written to {file}. 281 Example: > 282 nvim -V20vimlog 283< 284 *-D* 285-D Debugging. Go to debugging mode when executing the first 286 command from a script. |debug-mode| 287 288 *-n* 289-n Disables |swap-file| by setting 'updatecount' to 0 (after 290 executing any |vimrc|). Recovery after a crash will be 291 impossible. Improves performance when working with a file on 292 a very slow medium (usb drive, network share). 293 294 Enable it again by setting 'updatecount' to some value, e.g. 295 ":set updatecount=100". 296 297 To reduce accesses to the disk, don't use "-n", but set 298 'updatetime' and 'updatecount' to very big numbers, and type 299 ":preserve" when you want to save your work. This way you 300 keep the possibility for crash recovery. 301 302 *-o* 303-o[N] Open N windows, split horizontally. If [N] is not given, 304 one window is opened for every file given as argument. If 305 there is not enough room, only the first few files get a 306 window. If there are more windows than arguments, the last 307 few windows will be editing an empty file. 308 309 *-O* 310-O[N] Open N windows, split vertically. Otherwise, it's like -o. 311 If both the -o and the -O option are given, the last one on 312 the command line determines how the windows will be split. 313 314 *-p* 315-p[N] Open N tabpages. If [N] is not given, one tabpage is opened 316 for every file given as argument. The maximum is set with 317 'tabpagemax' pages (default 50). If there are more tabpages 318 than arguments, the last few tabpages will be editing an 319 empty file. Also see |tabpage|. 320 *-d* 321-d Start in |diff-mode|. 322 323 *-u* *E282* 324-u {vimrc} The file {vimrc} is read for initializations. Most other 325 initializations are skipped; see |initialization|. 326 327 This can be used to start Vim in a special mode, with special 328 mappings and settings. A shell alias can be used to make 329 this easy to use. For example, in a C shell descendant: > 330 alias vimc 'nvim -u ~/.config/nvim/c_init.vim \!*' 331< And in a Bash shell: > 332 alias vimc='nvim -u ~/.config/nvim/c_init.vim' 333< Also consider using autocommands; see |autocommand|. 334 335 When {vimrc} is "NONE" (all uppercase), all initializations 336 from files and environment variables are skipped. Plugins and 337 syntax highlighting are also skipped. 338 339 When {vimrc} is "NORC" (all uppercase), this has the same 340 effect as "NONE", but plugins and syntax highlighting are not 341 skipped. 342 343 *-i* 344-i {shada} The file {shada} is used instead of the default ShaDa 345 file. If the name "NONE" is used (all uppercase), no ShaDa 346 file is read or written, even if 'shada' is set or when 347 ":rsh" or ":wsh" are used. See also |shada-file|. 348 349 *-s* 350-s {scriptin} Read script file {scriptin}, interpreting characters as 351 Normal-mode input. The same can be done with ":source!": > 352 :source! {scriptin} 353< Reads from stdin if {scriptin} is "-": > 354 echo "ifoo" | nvim -s - 355< If the end of the file is reached before Nvim exits, further 356 characters are read from the keyboard. 357 358 Does not work with |-es|. See also |complex-repeat|. 359 360 *-w_nr* 361-w {number} 362-w{number} Set the 'window' option to {number}. 363 364 *-w* 365-w {scriptout} All keys that you type are recorded in the file "scriptout", 366 until you exit Vim. Useful to create a script file to be used 367 with "vim -s" or ":source!". Appends to the "scriptout" file 368 if it already exists. {scriptout} cannot start with a digit. 369 See also |vim.on_key()|. 370 See also |complex-repeat|. 371 372 *-W* 373-W {scriptout} Like -w, but do not append, overwrite an existing file. 374 375 *--api-info* 376--api-info Print msgpack-encoded |api-metadata| and exit. 377 378 *--embed* 379--embed Use stdin/stdout as a msgpack-RPC channel, so applications can 380 embed and control Nvim via the RPC |API|. If the channel is 381 closed (except by |:detach|), Nvim exits. 382 383 Waits for a client to call |nvim_ui_attach()| before sourcing 384 startup files and reading buffers, so that UIs can handle 385 (display) early messages, dialogs, etc. Clients can do other 386 requests before `nvim_ui_attach` (e.g. `nvim_get_api_info` for 387 feature-detection). During this pre-startup phase the user 388 config is of course not available (similar to `--cmd`). 389 390 Non-UI embedders must pass |--headless|, then startup will 391 continue without waiting for `nvim_ui_attach`: > 392 nvim --embed --headless 393< which is equivalent to: > 394 nvim --headless --cmd "call stdioopen({'rpc': v:true})" 395< 396 UI embedders that want the UI protocol on a socket (instead of 397 stdio) must pass |--listen| as well as |--embed|: > 398 nvim --embed --listen addr 399 400< See also: |ui-startup| |channel-stdio| 401 402 *--headless* 403--headless Start without UI, and do not wait for `nvim_ui_attach`. The 404 builtin TUI is not used, so stdio works as an arbitrary 405 communication channel. |channel-stdio| 406 407 Also useful for scripting (tests) to see messages that would 408 not be printed by |-es|. 409 410 To detect if a UI is available, check if |nvim_list_uis()| is 411 empty during or after |VimEnter|. 412 413 To read stdin as text, "-" must be given explicitly: 414 --headless cannot assume that stdin is just text. > 415 echo foo | nvim --headless +"%print" +"q!" - 416< 417 See also |--embed|. 418 See also |-es|, which also disables most messages. 419 420--listen {addr} *--listen* 421 Start |RPC| server on pipe or TCP address {addr}. Sets the 422 primary listen address |v:servername| to {addr}. |serverstart()| 423 424 To start the server on-demand with systemd, use a systemd 425 socket unit and associated service unit running: > 426 systemd-socket-proxyd --exit-idle-time 427< 428============================================================================== 429Initialization *initialization* *startup* 430 431At startup, Nvim checks environment variables and files and sets values 432accordingly, proceeding as follows: 433 4341. Set |v:starttime| and |v:startreason|. 435 4362. Set the 'shell' option. *SHELL* *COMSPEC* 437 The environment variable SHELL, if it exists, is used to set the 'shell' 438 option. On Win32, the COMSPEC variable is used if SHELL is not set. 439 4403. Process the arguments. 441 The options and file names from the command that start Vim are inspected. 442 The |-V| argument can be used to display or log what happens next, useful 443 for debugging the initializations. The |--cmd| arguments are executed. 444 Buffers are created for all files (but not loaded yet). 445 4464. Start a server (unless |--listen| was given) and set |v:servername|. 447 4485. Wait for UI to connect. 449 Nvim started with |--embed| waits for the UI to connect before proceeding 450 to load user configuration. 451 4526. Setup |default-mappings| and |default-autocmds|. Create |popup-menu|. 453 4547. Enable filetype and indent plugins. 455 Skipped if the "-u NONE" command line argument was given. 456 This does the same as: > 457 :runtime! ftplugin.vim indent.vim 458 4598. Load user config (execute Ex commands from files, environment, …). 460 $VIMINIT environment variable is read as one Ex command line (separate 461 multiple commands with '|' or <NL>). 462 *config* *init.vim* *init.lua* *vimrc* *exrc* 463 - A file containing initialization commands is generically called a "vimrc" 464 or config file. It can be Vimscript ("init.vim") or Lua ("init.lua"), 465 but not both. *E5422* See |vimrc-intro| |base-directories|. 466 The config file is located at: 467 - Unix ~/.config/nvim/init.vim (or init.lua) 468 - Windows ~/AppData/Local/nvim/init.vim (or init.lua) 469 - |$XDG_CONFIG_HOME| $XDG_CONFIG_HOME/nvim/init.vim (or init.lua) 470 471 - If Nvim was started with "-u {file}" then {file} is used as the config 472 and all initializations until 8. are skipped. $MYVIMRC is not set. 473 "nvim -u NORC" can be used to skip these initializations without reading 474 a file. "nvim -u NONE" also skips plugins and syntax highlighting. |-u| 475 476 - If Nvim was started with |-es| or |-Es| or |-l| all initializations until 477 "8" are skipped. 478 479 - a. *system-vimrc* *sysinit.vim* 480 The system vimrc file is read for initializations. If 481 nvim/sysinit.vim file exists in one of $XDG_CONFIG_DIRS, it will be 482 used. Otherwise the system vimrc file is used. The path of this file 483 is given by the |:version| command. Usually it's "$VIM/sysinit.vim". 484 485 - b. *VIMINIT* *EXINIT* *$MYVIMRC* 486 Locations searched for initializations, in order of preference. 487 $MYVIMRC is set to the first valid location unless it was already set 488 or when using $VIMINIT: 489 - $VIMINIT environment variable (Ex command line). 490 - User |config|: $XDG_CONFIG_HOME/nvim/init.vim (or init.lua). 491 - Other config: {dir}/nvim/init.vim (or init.lua) where {dir} is any 492 directory in $XDG_CONFIG_DIRS. 493 - $EXINIT environment variable (Ex command line). 494 495 - c. If the 'exrc' option is on, the |current-directory| is searched until 496 one of these files is found, in order of precedence: 497 - ".nvim.lua" 498 - ".nvimrc" 499 - ".exrc" 500 5019. Enable filetype detection. 502 Skipped if ":filetype off" was called or if the "-u NONE" command line 503 argument was given. This does the same as: > 504 :runtime! filetype.lua 505 50610. Enable syntax highlighting. 507 Skipped if ":syntax off" was called or if the "-u NONE" command line 508 argument was given. This does the same as: > 509 :runtime! syntax/syntax.vim 510 51111. Set the |v:vim_did_init| variable to 1. 512 51312. Load the plugin scripts. *load-plugins* 514 This does the same as: 515 `:runtime! plugin/**/*.{vim,lua}` 516 - The result is that all directories in 'runtimepath' will be searched for 517 the "plugin" sub-directory and all files ending in ".vim" or ".lua" will 518 be sourced (in alphabetical order per directory), also in 519 subdirectories. First "*.vim" are sourced, then "*.lua" files, per 520 directory. 521 - However, directories in 'runtimepath' ending in "after" are skipped here 522 and only loaded after packages, see below. 523 - Loading plugins won't be done when: 524 - The 'loadplugins' option was reset in a vimrc file. 525 - The |--noplugin| command line argument is used. 526 - The |--clean| command line argument is used. 527 - The "-u NONE" command line argument is used |-u|. 528 - Note that using `-c 'set noloadplugins'` doesn't work, because the 529 commands from the command line have not been executed yet. You can use 530 `--cmd 'set noloadplugins'` or `--cmd 'set loadplugins'` |--cmd|. 531 - Packages are loaded. These are plugins, as above, but found in the 532 "start" directory of each entry in 'packpath'. Every plugin directory 533 found is added in 'runtimepath' and then the plugins are sourced. See 534 |packages|. 535 - The plugins scripts are loaded, as above, but now only the directories 536 ending in "after" are used. Note that 'runtimepath' will have changed 537 if packages have been found, but that should not add a directory ending 538 in "after". 539 54013. Set 'shellpipe' and 'shellredir', according to the value of the 'shell' 541 option, unless they were already set. Nvim will figure out the values of 542 'shellpipe' and 'shellredir' for you, unless you have set them yourself. 543 54414. Set 'updatecount' to zero, if |-n| was given. 545 54615. Set binary options if |-b| was given. 547 54816. Read the |shada-file|. 549 55017. Read the quickfix file if |-q| was given, or exit on failure. 551 55218. Open all windows. 553 - When |-o| was given, windows will be opened (but not displayed yet). 554 - When |-p| was given, tabpages will be created (but not displayed yet). 555 - When switching screens, it happens now. Redrawing starts. 556 - If |-q| was given, the first error is jumped to. 557 - Buffers for all windows will be loaded, without triggering |BufAdd|. 558 55919. Execute startup commands. 560 - If |-t| was given, the tag is jumped to. 561 - Commands given with |-c| and |+cmd| are executed. 562 - The |vim_starting| flag is reset, `has("vim_starting")` will now return zero. 563 - The |v:vim_did_enter| variable is set to 1. 564 - The |VimEnter| autocommands are executed. 565 566 567Saving the current state of Vim to a file ~ 568 569Whenever you have changed values of options or when you have created a 570mapping, then you may want to save them in a vimrc file for later use. See 571|save-settings| about saving the current state of settings to a file. 572 573 574Avoiding trojan horses ~ 575 *trojan-horse* 576While reading the "vimrc" or the "exrc" file in the current directory, some 577commands can be disabled for security reasons by setting the 'secure' option. 578This is always done when executing the command from a tags file. Otherwise, 579it would be possible that you accidentally use a vimrc or tags file that 580somebody else created and contains nasty commands. The disabled commands are 581the ones that start a shell, the ones that write to a file, and ":autocmd". 582The ":map" commands are echoed, so you can see which keys are being mapped. 583 584If you want Vim to execute all commands in a local vimrc file, you can reset 585the 'secure' option in the EXINIT or VIMINIT environment variable or in the 586global exrc or vimrc file. This is not possible in vimrc or exrc in the 587current directory, for obvious reasons. 588 589On Unix systems, this only happens if you are not the owner of the 590vimrc file. Warning: If you unpack an archive that contains a vimrc or exrc 591file, it will be owned by you. You won't have the security protection. Check 592the vimrc file before you start Vim in that directory, or reset the 'exrc' 593option. Some Unix systems allow a user to do "chown" on a file. This makes 594it possible for another user to create a nasty vimrc and make you the owner. 595Be careful! 596 597When using tag search commands, executing the search command (the last part of 598the line in the tags file) is always done in secure mode. This works just 599like executing a command from a vimrc in the current directory. 600 601 602If Vim startup is slow ~ 603 *slow-start* 604If Vim takes a long time to start up, use the |--startuptime| argument to find 605out what happens. 606 607If you have 'shada' enabled, the loading of the ShaDa file may take a 608while. You can find out if this is the problem by disabling ShaDa for a 609moment (use the Vim argument "-i NONE", |-i|). Try reducing the number of 610lines stored in a register with ":set shada='20,<50,s10". |shada-file|. 611 612 613Troubleshooting broken configurations ~ 614 *bisect* 615The extreme flexibility of editors like Vim and Emacs means that any plugin or 616setting can affect the entire editor in ways that are not initially obvious. 617 618To find the cause of a problem in your config, you must "bisect" it: 6191. Remove or disable half of your |config|. 6202. Restart Nvim (|:restart|). 6213. If the problem still occurs, goto 1. 6224. If the problem is gone, restore half of the removed lines. 6235. Continue narrowing your config in this way, until you find the setting or 624 plugin causing the issue. 625 626 627Intro message ~ 628 *:intro* 629When Vim starts without a file name, an introductory message is displayed. It 630is removed as soon as the display is redrawn. To see the message again, use 631the ":intro" command. To avoid the intro message on startup, add the "I" flag 632to 'shortmess'. 633 634============================================================================== 635$VIM and $VIMRUNTIME 636 *$VIM* 637The environment variable "$VIM" is used to locate various user files for Nvim, 638such as the user |config|. This depends on the system, see 639|startup|. 640 641Nvim will try to get the value for $VIM in this order: 642 6431. Environment variable $VIM, if it is set. 6442. Path derived from the 'helpfile' option, unless it contains some 645 environment variable too (default is "$VIMRUNTIME/doc/help.txt"). File 646 name ("help.txt", etc.) is removed. Trailing directory names are removed, 647 in this order: "doc", "runtime". 6483. Path derived from the location of the `nvim` executable. 6494. Compile-time defined installation directory (see output of ":version"). 650 651After doing this once, Nvim sets the $VIM environment variable. 652 653 *$VIMRUNTIME* 654The environment variable "$VIMRUNTIME" is used to locate various support 655files, such as the documentation and syntax-highlighting files. For example, 656the main help file is normally "$VIMRUNTIME/doc/help.txt". 657 658Nvim will try to get the value for $VIMRUNTIME in this order: 659 6601. Environment variable $VIMRUNTIME, if it is set. 6612. Directory path "$VIM/runtime", if it exists. 6623. Value of $VIM environment variable. This is for backwards compatibility 663 with older Vim versions. 6644. If "../share/nvim/runtime" exists relative to |v:progpath|, it is used. 6655. Path derived from the 'helpfile' option (if it doesn't contain '$') with 666 "doc/help.txt" removed from the end. 667 668After doing this once, Nvim sets the $VIMRUNTIME environment variable. 669 670In case you need the value of $VIMRUNTIME in a shell (e.g., for a script that 671greps in the help files) you might be able to use this: > 672 673 VIMRUNTIME="$(nvim --clean --headless --cmd 'echo $VIMRUNTIME|q')" 674 675============================================================================== 676Suspending *suspend* 677 678 *CTRL-Z* *v_CTRL-Z* 679CTRL-Z Suspend Nvim, like ":stop". 680 Works in Normal and in Visual mode. In Insert and 681 Command-line mode, the CTRL-Z is inserted as a normal 682 character. In Visual mode Nvim goes back to Normal 683 mode before suspending. 684 685:sus[pend][!] or *:sus* *:suspend* *:st* *:stop* 686:st[op][!] Suspend Nvim using OS "job control"; it will continue 687 if you make it the foreground job again. Triggers 688 |VimSuspend| before suspending and |VimResume| when 689 resumed. 690 691 If "!" is not given and 'autowrite' is set, every 692 buffer with changes and a file name is written out. 693 If "!" is given or 'autowrite' is not set, changed 694 buffers are not written, don't forget to bring Nvim 695 back to the foreground later! 696 697In the GUI, suspending is implementation-defined. 698 699============================================================================== 700Exiting *exiting* 701 702There are several ways to exit Vim: 703- Close the last window with `:quit`. Only when there are no changes. 704- Close the last window with `:quit!`. Also when there are changes. 705- Close all windows with `:qall`. Only when there are no changes. 706- Close all windows with `:qall!`. Also when there are changes. 707- Use `:cquit`. Also when there are changes. 708 709When using `:cquit` or when there was an error message Vim exits with exit 710code 1. Errors can be avoided by using `:silent!` or with `:catch`. 711 712============================================================================== 713Saving settings *save-settings* 714 715Mostly you will edit your vimrc files manually. This gives you the greatest 716flexibility. There are a few commands to generate a vimrc file automatically. 717You can use these files as they are, or copy/paste lines to include in another 718vimrc file. 719 720 *:mk* *:mkexrc* 721:mk[exrc] [file] Write current key mappings and changed options to 722 [file] (default ".exrc" in the current directory), 723 unless it already exists. 724 725:mk[exrc]! [file] Always write current key mappings and changed 726 options to [file] (default ".exrc" in the current 727 directory). 728 729 *:mkv* *:mkvi* *:mkvimrc* 730:mkv[imrc][!] [file] Like ":mkexrc", but the default is ".nvimrc" in the 731 current directory. The ":version" command is also 732 written to the file. 733 734These commands will write ":map" and ":set" commands to a file, in such a way 735that when these commands are executed, the current key mappings and options 736will be set to the same values. The options 'columns', 'endofline', 737'fileformat', 'lines', 'modified', and 'scroll' are not included, because 738these are terminal or file dependent. 739Note that the options 'binary', 'paste' and 'readonly' are included, this 740might not always be what you want. 741 742When special keys are used in mappings, the 'cpoptions' option will be 743temporarily set to its Vim default, to avoid the mappings to be 744misinterpreted. This makes the file incompatible with Vi, but makes sure it 745can be used with different terminals. 746 747Only global mappings are stored, not mappings local to a buffer. 748 749A common method is to use a default |config| file, make some modifications 750with ":map" and ":set" commands and write the modified file. First read the 751default vimrc in with a command like ":source ~piet/.vimrc.Cprogs", change 752the settings and then save them in the current directory with ":mkvimrc!". If 753you want to make this file your default |config|, move it to 754$XDG_CONFIG_HOME/nvim. You could also use autocommands |autocommand| and/or 755modelines |modeline|. 756 757 *vimrc-option-example* 758If you only want to add a single option setting to your vimrc, you can use 759these steps: 7601. Edit your vimrc file with Vim. 7612. Play with the option until it's right. E.g., try out different values for 762 'guifont'. 7633. Append a line to set the value of the option, using the expression register 764 '=' to enter the value. E.g., for the 'guifont' option: > 765 o:set guifont=<C-R>=&guifont<CR><Esc> 766< [<C-R> is a CTRL-R, <CR> is a return, <Esc> is the escape key] 767 You need to escape special characters, esp. spaces. 768 769============================================================================== 770Views and Sessions *views-sessions* 771 772This is introduced in sections |21.4| and |21.5| of the user manual. 773 774 *View* *view-file* 775A View is a collection of settings that apply to one window. You can save a 776View and when you restore it later, the text is displayed in the same way. 777The options and mappings in this window will also be restored, so that you can 778continue editing like when the View was saved. 779 780 *Session* *session-file* 781A Session keeps the Views for all windows, plus the global settings. You can 782save a Session and when you restore it later the window layout looks the same. 783You can use a Session to quickly switch between different projects, 784automatically loading the files you were last working on in that project. 785 786Views and Sessions are a nice addition to ShaDa files, which are used to 787remember information for all Views and Sessions together |shada-file|. 788 789You can quickly start editing with a previously saved View or Session with the 790|-S| argument: > 791 vim -S Session.vim 792< 793 *:mks* *:mksession* 794:mks[ession][!] [file] Write a Vim script that restores the current editing 795 session. 796 When [!] is included, an existing file is overwritten. 797 When [file] is omitted, "Session.vim" is used. 798 799The output of ":mksession" is like ":mkvimrc", but additional commands are 800added to the file. Which ones depends on the 'sessionoptions' option. The 801resulting file, when executed with a ":source" command: 8021. Restores global mappings and options, if 'sessionoptions' contains 803 "options". Lua functions, and script-local mappings, will not be written. 8042. Restores global variables that start with an uppercase letter and contain 805 at least one lowercase letter, if 'sessionoptions' contains "globals". 8063. Closes all windows in the current tabpage, except the current one; closes 807 all tabpages except the current one (this results in currently loaded 808 buffers to be unloaded, some may become hidden if 'hidden' is set or 809 otherwise specified); wipes out the current buffer, if it is empty and 810 unnamed. 8114. Restores the current directory, if 'sessionoptions' contains "curdir", or 812 sets the current directory to where the Session file is, if 813 'sessionoptions' contains "sesdir". 8145. Restores GUI Vim window position, if 'sessionoptions' contains "winpos". 8156. Restores screen size, if 'sessionoptions' contains "resize". 8167. Reloads the buffer list, with the last cursor positions. If 817 'sessionoptions' contains "buffers" then all buffers are restored, 818 including hidden and unloaded buffers. Otherwise, only buffers in windows 819 are restored. 8208. Restores all windows with the same layout. If 'sessionoptions' contains 821 "help", help windows are restored. If 'sessionoptions' contains "blank", 822 windows editing a buffer without a name will be restored. 823 If 'sessionoptions' contains "winsize" and no (help/blank) windows were 824 left out, the window sizes are restored (relative to the screen size). 825 Otherwise, the windows are just given sensible sizes. 8269. Restores the Views for all the windows, as with |:mkview|. But 827 'sessionoptions' is used instead of 'viewoptions'. 82810. If a file exists with the same name as the Session file, but ending in 829 "x.vim" (for eXtra), executes that as well. You can use `*x.vim` files to 830 specify additional settings and actions associated with a given Session, 831 such as creating menu items in the GUI version. 832 833After restoring the Session, the full filename of your current Session is 834available in the internal variable |v:this_session|. 835An example mapping: > 836 :nmap <F2> :wa<Bar>exe "mksession! " .. v:this_session<CR>:so ~/sessions/ 837This saves the current Session, and starts off the command to load another. 838 839A session includes all tabpages, unless "tabpages" was removed from 840'sessionoptions'. |tabpage| 841 842The |SessionLoadPre| autocmd event is triggered before a session file is 843loaded/sourced and |SessionLoadPost| autocmd event is triggered after. 844 *SessionLoad-variable* 845While the session file is loading, `g:SessionLoad` is set to 1. Plugins can 846use this to postpone some work until the SessionLoadPost event is triggered. 847 848 *:mkvie* *:mkview* 849:mkvie[w][!] [file] Write a Vim script that restores the contents of the 850 current window. 851 When [!] is included, an existing file is overwritten. 852 When [file] is omitted or is a number from 1 to 9, a 853 name is generated and 'viewdir' prepended. When the 854 last path part of 'viewdir' does not exist, this 855 directory is created. E.g., when 'viewdir' is 856 "$VIM/vimfiles/view" then "view" is created in 857 "$VIM/vimfiles". 858 An existing file is always overwritten then. Use 859 |:loadview| to load this view again. 860 When [file] is the name of a file ('viewdir' is not 861 used), a command to edit the file is added to the 862 generated file. 863 864The output of ":mkview" contains these items: 8651. The argument list used in the window. When the global argument list is 866 used, it is reset to the global list. 867 The index in the argument list is also restored. 8682. The file being edited in the window. If there is no file, the window is 869 made empty. 8703. Restore mappings, abbreviations and options local to the window, if 871 'viewoptions' contains "options" or "localoptions". Only option values 872 that are local to the current buffer and the current window are restored. 873 When storing the view as part of a session and "options" is in 874 'sessionoptions', global values for local options will be stored too. 875 Lua functions are not restored. 8764. Restore folds when using manual folding and 'viewoptions' contains 877 "folds". Restore manually opened and closed folds. 8785. The scroll position and the cursor position in the file. Doesn't work very 879 well when there are closed folds. 8806. The local current directory, if it is different from the global current 881 directory and 'viewoptions' contains "curdir". 882 883Note that Views and Sessions are not perfect: 884- They don't restore everything. For example, defined functions, autocommands 885 and ":syntax on" are not included. Things like register contents and 886 command line history are in ShaDa, not in Sessions or Views. 887- Global option values are only set when they differ from the default value. 888 When the current value is not the default value, loading a Session will not 889 set it back to the default value. Local options will be set back to the 890 default value though. 891- Existing mappings will be overwritten without warning. An existing mapping 892 may cause an error for ambiguity. 893- When storing manual folds and when storing manually opened/closed folds, 894 changes in the file between saving and loading the view will mess it up. 895- The Vim script is not very efficient. But still faster than typing the 896 commands yourself! 897 898 *:lo* *:loadview* 899:lo[adview] [nr] Load the view for the current file. When [nr] is 900 omitted, the view stored with ":mkview" is loaded. 901 When [nr] is specified, the view stored with ":mkview 902 [nr]" is loaded. 903 904The combination of ":mkview" and ":loadview" can be used to store up to ten 905different views of a file. These are remembered in the directory specified 906with the 'viewdir' option. The views are stored using the file name. If a 907file is renamed or accessed through a (symbolic) link, the view will not be 908found. 909 910You might want to clean up your 'viewdir' directory now and then. 911 912To automatically save and restore views for `*.c` files: > 913 au BufWinLeave *.c mkview 914 au BufWinEnter *.c silent! loadview 915 916============================================================================== 917Shada ("shared data") file *shada* *shada-file* 918 919If you exit Vim and later start it again, you would normally lose a lot of 920information. The ShaDa file can be used to remember that information, which 921enables you to continue where you left off. Its name is the abbreviation of 922SHAred DAta because it is used for sharing data between Nvim sessions. 923 924This is introduced in section |21.3| of the user manual. 925 926The ShaDa file is used to store: 927- The command line history. 928- The search string history. 929- The input-line history. 930- Contents of non-empty registers. 931- Marks for several files. 932- File marks, pointing to locations in files. 933- Last search/substitute pattern (for 'n' and '&'). 934- The buffer list. 935- Global variables. 936 937You could also use a Session file. The difference is that the ShaDa file 938does not depend on what you are working on. There normally is only one 939ShaDa file. Session files are used to save the state of a specific editing 940Session. You could have several Session files, one for each project you are 941working on. ShaDa and Session files together can be used to effectively 942enter Vim and directly start working in your desired setup. |session-file| 943 944 *shada-read* 945When Vim is started and the 'shada' option is non-empty, the contents of 946the ShaDa file are read and the info can be used in the appropriate places. 947The |v:oldfiles| variable is filled. The marks are not read in at startup 948(but file marks are). See |initialization| for how to set the 'shada' 949option upon startup. 950 951 *shada-write* 952When Vim exits and 'shada' is non-empty, the info is stored in the ShaDa file 953(it's actually merged with the existing one, if one exists |shada-merging|). 954The 'shada' option is a string containing information about what info should 955be stored, and contains limits on how much should be stored (see 'shada'). 956 957Notes for Unix: 958- The file protection for the ShaDa file will be set to prevent other users 959 from being able to read it, because it may contain any text or commands that 960 you have worked with. 961- If you want to share the ShaDa file with other users (e.g. when you "su" 962 to another user), you can make the file writable for the group or everybody. 963 Vim will preserve this when writing new ShaDa files. Be careful, don't 964 allow just anybody to read and write your ShaDa file! 965- Vim will not overwrite a ShaDa file that is not writable by the current 966 "real" user. This helps for when you did "su" to become root, but your 967 $HOME is still set to a normal user's home directory. Otherwise, Vim would 968 create a ShaDa file owned by root that nobody else can read. 969- The ShaDa file cannot be a symbolic link. This is to avoid security 970 issues. 971 972Marks are stored for each file separately. When a file is read and 'shada' 973is non-empty, the marks for that file are read from the ShaDa file. NOTE: 974The marks are only written when exiting Vim, which is fine because marks are 975remembered for all the files you have opened in the current editing session, 976unless ":bdel" is used. If you want to save the marks for a file that you are 977about to abandon with ":bdel", use ":wsh". The '[' and ']' marks are not 978stored, but the '"' mark is. The '"' mark is very useful for jumping to the 979cursor position when the file was last exited. No marks are saved for files 980that start with any string given with the "r" flag in 'shada'. This can be 981used to avoid saving marks for files on removable media (for MS-Windows you 982would use "ra:,rb:"). 983The |v:oldfiles| variable is filled with the file names that the ShaDa file 984has marks for. 985 986 *shada-file-marks* 987Uppercase marks ('A to 'Z) are stored when writing the ShaDa file. The 988numbered marks ('0 to '9) are a bit special. When the ShaDa file is written 989(when exiting or with the |:wshada| command), '0 is set to the current 990cursor position and file. The old '0 is moved to '1, '1 to '2, etc. This 991resembles what happens with the "1 to "9 delete registers. If the current 992cursor position is already present in '0 to '9, it is moved to '0, to avoid 993having the same position twice. The result is that with "'0", you can jump 994back to the file and line where you exited Vim. To do that right away, try 995using this command: > 996 997 vim -c "normal '0" 998 999In a C shell descendant, you could make an alias for it: > 1000 1001 alias lvim vim -c '"'normal "'"0'"' 1002 1003For a Bash-like shell: > 1004 1005 alias lvim='vim -c "normal '\''0"' 1006 1007Use the "r" flag in 'shada' to specify for which files no marks should be 1008remembered. 1009 1010MERGING *shada-merging* 1011 1012When writing ShaDa files with |:wshada| without bang or at regular exit 1013information in the existing ShaDa file is merged with information from current 1014Nvim instance. For this purpose ShaDa files store timestamps associated 1015with ShaDa entries. Specifically the following is being done: 1016 10171. History lines are merged, ordered by timestamp. Maximum amount of items in 1018 ShaDa file is defined by 'shada' option (|shada-/|, |shada-:|, |shada-@|, 1019 etc: one suboption for each character that represents history name 1020 (|:history|)). 10212. Local marks and changes for files that were not opened by Nvim are copied 1022 to new ShaDa file. Marks for files that were opened by Nvim are merged, 1023 changes to files opened by Nvim are ignored. |shada-'| 10243. Jump list is merged: jumps are ordered by timestamp, identical jumps 1025 (identical position AND timestamp) are squashed. 10264. Search patterns and substitute strings are not merged: search pattern or 1027 substitute string which has greatest timestamp will be the only one copied 1028 to ShaDa file. 10295. For each register entity with greatest timestamp is the only saved. 1030 |shada-<| 10316. All saved variables are saved from current Nvim instance. Additionally 1032 existing variable values are copied, meaning that the only way to remove 1033 variable from a ShaDa file is either removing it by hand or disabling 1034 writing variables completely. |shada-!| 10357. For each global mark entity with greatest timestamp is the only saved. 10368. Buffer list and header are the only entries which are not merged in any 1037 fashion: the only header and buffer list present are the ones from the 1038 Nvim instance which was last writing the file. |shada-%| 1039 1040COMPATIBILITY *shada-compatibility* 1041 1042ShaDa files are forward and backward compatible. This means that 1043 10441. Entries which have unknown type (i.e. that hold unidentified data) are 1045 ignored when reading and blindly copied when writing. 10462. Register entries with unknown register name are ignored when reading and 1047 blindly copied when writing. Limitation: only registers that use name with 1048 code in interval [1, 255] are supported. |registers| 10493. Register entries with unknown register type are ignored when reading and 1050 merged as usual when writing. |getregtype()| 10514. Local and global mark entries with unknown mark names are ignored when 1052 reading. When writing global mark entries are blindly copied and local mark 1053 entries are also blindly copied, but only if file they are attached to fits 1054 in the |shada-'| limit. Unknown local mark entry's timestamp is also taken 1055 into account when calculating which files exactly should fit into this 1056 limit. Limitation: only marks that use name with code in interval [1, 255] 1057 are supported. |mark-motions| 10585. History entries with unknown history type are ignored when reading and 1059 blindly copied when writing. Limitation: there can be only up to 256 1060 history types. |history| 10616. Unknown keys found in register, local mark, global mark, change, jump and 1062 search pattern entries are saved internally and dumped when writing. 1063 Entries created during Nvim session never have such additions. 10647. Additional elements found in replacement string and history entries are 1065 saved internally and dumped. Entries created during Nvim session never 1066 have such additions. 10678. Additional elements found in variable entries are simply ignored when 1068 reading. When writing new variables they will be preserved during merging, 1069 but that's all. Variable values dumped from current Nvim session never 1070 have additional elements, even if variables themselves were obtained by 1071 reading ShaDa files. 1072 1073"Blindly" here means that there will be no attempts to somehow merge them, 1074even if other entries (with known name/type/etc) are merged. |shada-merging| 1075 1076SHADA FILE NAME *shada-file-name* 1077 1078- Default name of the |shada| file is: 1079 Unix: "$XDG_STATE_HOME/nvim/shada/main.shada" 1080 Windows: "$XDG_STATE_HOME/nvim-data/shada/main.shada" 1081 See also |base-directories|. 1082- To choose a different file name you can use: 1083 - The "n" flag in the 'shada' option. 1084 - The |-i| startup argument. "NONE" means no shada file is ever read or 1085 written. Also not for the commands below! 1086 - The 'shadafile' option. The value from the "-i" argument (if any) is 1087 stored in the 'shadafile' option. 1088- For the commands below, another file name can be given, overriding the 1089 default and the name given with 'shada' or "-i" (unless it's NONE). 1090 1091 1092MANUALLY READING AND WRITING *shada-read-write* 1093 1094Two commands can be used to read and write the ShaDa file manually. This 1095can be used to exchange registers between two running Vim programs: First 1096type ":wsh" in one and then ":rsh" in the other. Note that if the register 1097already contained something, then ":rsh!" would be required. Also note, 1098however, that this means everything will be overwritten with information from 1099the first Vim, including the command line history, etc. 1100 1101The ShaDa file itself can be edited by hand too, although we suggest you 1102start with an existing one to get the format right. You need to understand 1103MessagePack (or, more likely, find software that is able to use it) format to 1104do this. This can be useful in order to create a second file, say 1105"~/.my.shada", which could contain certain settings that you always want when 1106you first start Nvim. For example, you can preload registers with 1107particular data, or put certain commands in the command line history. A line 1108in your |config| file like > 1109 :rshada! ~/.my.shada 1110can be used to load this information. You could even have different ShaDa 1111files for different types of files (e.g., C code) and load them based on the 1112file name, using the ":autocmd" command (see |:autocmd|). More information on 1113ShaDa file format is contained in |shada-format| section. 1114 1115 *E136* *E929* *shada-error-handling* 1116Some errors make Nvim leave temporary file named `{basename}.tmp.X` (X is 1117any free letter from `a` to `z`) while normally it will create this file, 1118write to it and then rename `{basename}.tmp.X` to `{basename}`. Such errors 1119include: 1120 1121- Errors which make Nvim think that the file being read is not a ShaDa 1122 file at all: 1123 non-ShaDa files are not overwritten for safety reasons to avoid accidentally 1124 destroying an unrelated file. This could happen e.g. when typing "nvim -i 1125 file" in place of "nvim -R file" (yes, somebody did that at least with Vim). 1126 Such errors are listed at |shada-critical-contents-errors|. 1127- If writing to the temporary file failed: e.g. because of the insufficient 1128 space left. 1129- If renaming file failed: e.g. because of insufficient permissions. 1130- If target ShaDa file has different from the Nvim instance's owners (user 1131 and group) and changing them failed. Unix-specific, applies only when 1132 Nvim was launched from root. 1133 1134Do not forget to remove the temporary file or replace the target file with 1135temporary one after getting one of the above errors or all attempts to create 1136a ShaDa file may fail with |E929|. If you got one of them when using 1137|:wshada| (and not when exiting Nvim: i.e. when you have Nvim session 1138running) you have additional options: 1139 1140- First thing which you should consider if you got any error, except failure 1141 to write to the temporary file: remove existing file and replace it with the 1142 temporary file. Do it even if you have running Nvim instance. 1143- Fix the permissions and/or file ownership, free some space and attempt to 1144 write again. Do not remove the existing file. 1145- Use |:wshada| with bang. Does not help in case of permission error. If 1146 target file was actually the ShaDa file some information may be lost in this 1147 case. To make the matters slightly better use |:rshada| prior to writing, 1148 but this still will loose buffer-local marks and change list entries for any 1149 file which is not opened in the current Nvim instance. 1150- Remove the target file from shell and use |:wshada|. Consequences are not 1151 different from using |:wshada| with bang, but "rm -f" works in some cases 1152 when you don't have write permissions. 1153 1154 *:rsh* *:rshada* *E886* 1155:rsh[ada][!] [file] Read from ShaDa file [file] (default: see above). 1156 If [!] is given, then any information that is 1157 already set (registers, marks, |v:oldfiles|, etc.) 1158 will be overwritten. 1159 1160 *:wsh* *:wshada* *E137* *E138* 1161:wsh[ada][!] [file] Write to ShaDa file [file] (default: see above). 1162 The information in the file is first read in to make 1163 a merge between old and new info. When [!] is used, 1164 the old information is not read first, only the 1165 internal info is written (also disables safety checks 1166 described in |shada-error-handling|). If 'shada' is 1167 empty, marks for up to 100 files will be written. 1168 When you get error "E929: All .tmp.X files exist, 1169 cannot write ShaDa file!", check that no old temp 1170 files were left behind (e.g. 1171 ~/.local/state/nvim/shada/main.shada.tmp*). 1172 1173 Note: Executing :wshada will reset all |'quote| marks. 1174 1175 *:o* *:ol* *:oldfiles* 1176:o[ldfiles] List the files that have marks stored in the ShaDa 1177 file. This list is read on startup and only changes 1178 afterwards with `:rshada!`. Also see |v:oldfiles|. 1179 The number can be used with |c_#<|. 1180 The output can be filtered with |:filter|, e.g.: > 1181 filter /\.vim/ oldfiles 1182< The filtering happens on the file name. 1183 1184:bro[wse] o[ldfiles][!] 1185 List file names as with |:oldfiles|, and then prompt 1186 for a number. When the number is valid that file from 1187 the list is edited. 1188 1189 Use [!] to abandon a modified buffer. |abandon| 1190 1191SHADA FILE FORMAT *shada-format* 1192 1193ShaDa files are concats of MessagePack entries. Each entry is a concat of 1194exactly four MessagePack objects: 1195 11961. First goes type of the entry. Object type must be an unsigned integer. 1197 Object type must not be equal to zero. 11982. Second goes entry timestamp. It must also be an unsigned integer. 11993. Third goes the length of the fourth entry. Unsigned integer as well, used 1200 for fast skipping without parsing. 12014. Fourth is actual entry data. All currently used ShaDa entries use 1202 containers to hold data: either map or array. All string values in those 1203 containers are either binary (applies to filenames) or UTF-8, yet parser 1204 needs to expect that invalid bytes may be present in a UTF-8 string. 1205 1206 Exact format depends on the entry type: 1207 1208 Entry type (name) Entry data ~ 1209 1210 - 1 (Header) Map containing data that describes the generator 1211 instance that wrote this ShaDa file. It is ignored 1212 when reading ShaDa files. Contains the following data: 1213 Key Data > 1214 generator Binary, software used to generate ShaDa 1215 file. Is equal to "nvim" when ShaDa file was 1216 written by Nvim. 1217 version Binary, generator version. 1218 encoding Binary, effective 'encoding' value. 1219 max_kbyte Integer, effective |shada-s| limit value. 1220 pid Integer, instance process ID. 1221 * It is allowed to have any number of 1222 additional keys with any data. 1223< 1224 - 2 (SearchPattern) Map containing data describing last used search or 1225 substitute pattern. Normally ShaDa file contains two 1226 such entries: one with "ss" key set to true (describes 1227 substitute pattern, see |:substitute|), and one set to 1228 false (describes search pattern, see 1229 |search-commands|). "su" key should be true on one of 1230 the entries. If key value is equal to default then it 1231 is normally not present. Keys: 1232 Key Type Default Description > 1233 sm Boolean true Effective 'magic' value. 1234 sc Boolean false Effective 'smartcase' value. 1235 sl Boolean true True if search pattern comes 1236 with a line offset. See 1237 |search-offset|. 1238 se Boolean false True if |search-offset| 1239 requested to place cursor at 1240 (relative to) the end of the 1241 pattern. 1242 so Integer 0 Offset value. |search-offset| 1243 su Boolean false True if current entry was the 1244 last used search pattern. 1245 ss Boolean false True if current entry describes 1246 |:substitute| pattern. 1247 sh Boolean false True if |v:hlsearch| is on. 1248 With |shada-h| or 'nohlsearch' 1249 this key is always false. 1250 sp Binary N/A Actual pattern. Required. 1251 sb Boolean false True if search direction is 1252 backward. 1253 * any none Other keys are allowed for 1254 compatibility reasons, see 1255 |shada-compatibility|. 1256< 1257 - 3 (SubString) Array containing last |:substitute| replacement string. 1258 Contains single entry: binary, replacement string used. 1259 More entries are allowed for compatibility reasons, see 1260 |shada-compatibility|. 1261 - 4 (HistoryEntry) Array containing one entry from history. Should have 1262 two or three entries. First one is history type 1263 (unsigned integer), second is history line (binary), 1264 third is the separator character (unsigned integer, 1265 must be in interval [0, 255]). Third item is only 1266 valid for search history. Possible history types are 1267 listed in |hist-names|, here are the corresponding 1268 numbers: 0 - cmd, 1 - search, 2 - expr, 3 - input, 1269 4 - debug. 1270 - 5 (Register) Map describing one register (|registers|). If key 1271 value is equal to default then it is normally not 1272 present. Keys: 1273 Key Type Def Description > 1274 rt UInteger 0 Register type: 1275 No Description ~ 1276 0 |charwise-register| 1277 1 |linewise-register| 1278 2 |blockwise-register| 1279 rw UInteger 0 Register width. Only valid 1280 for |blockwise-register|s. 1281 rc Array of binary N/A Register contents. Each 1282 entry in the array 1283 represents its own line. 1284 NUL characters inside the 1285 line should be represented 1286 as NL according to 1287 |NL-used-for-Nul|. 1288 ru Boolean false Unnamed register. Whether 1289 the unnamed register had 1290 pointed to this register. 1291 n UInteger N/A Register name: character 1292 code in range [1, 255]. 1293 Example: |quote0| register 1294 has name 48 (ASCII code for 1295 zero character). 1296 * any none Other keys are allowed 1297 for compatibility reasons, 1298 see |shada-compatibility|. 1299< 1300 - 6 (Variable) Array containing two items: variable name (binary) and 1301 variable value (any object). Values are converted 1302 using the same code |msgpackparse()| uses when reading, 1303 |msgpackdump()| when writing, so there may appear 1304 |msgpack-special-dict|s. If there are more then two 1305 entries then the rest are ignored 1306 (|shada-compatibility|). 1307 - 7 (GlobalMark) 1308 - 8 (Jump) 1309 - 10 (LocalMark) 1310 - 11 (Change) Map containing some position description: 1311 Entry Position > 1312 GlobalMark Global mark position. |'A| 1313 LocalMark Local mark position. |'a| 1314 Jump One position from the |jumplist|. 1315 Change One position from the |changelist|. 1316 1317 Data contained in the map: 1318 Key Type Default Description ~ 1319 l UInteger 1 Position line number. Must be 1320 greater then zero. 1321 c UInteger 0 Position column number. 1322 n UInteger 34 ('"') Mark name. Only valid for 1323 GlobalMark and LocalMark 1324 entries. 1325 f Binary N/A File name. Required. 1326 * any none Other keys are allowed for 1327 compatibility reasons, see 1328 |shada-compatibility|. 1329< 1330 - 9 (BufferList) Array containing maps. Each map in the array 1331 represents one buffer. Possible keys: 1332 Key Type Default Description > 1333 l UInteger 1 Position line number. Must be 1334 greater then zero. 1335 c UInteger 0 Position column number. 1336 f Binary N/A File name. Required. 1337 * any none Other keys are allowed for 1338 compatibility reasons, see 1339 |shada-compatibility|. 1340< 1341 - `*` (Unknown) Any other entry type is allowed for compatibility 1342 reasons, see |shada-compatibility|. 1343 1344 *E574* *E575* *E576* 1345Errors in ShaDa file may have two types: 13461. E575 for “logical” errors. 13472. E576 for “critical” errors. 1348 1349When writing, critical errors trigger behaviour described in 1350|shada-error-handling|. 1351When reading, critical errors cause the rest of the file to be skipped. 1352 1353Critical errors include: 1354 *shada-critical-contents-errors* 1355- Any of first three MessagePack objects being not an unsigned integer. 1356- Third object requesting amount of bytes greater then bytes left in the ShaDa 1357 file. 1358- Entry with zero type. I.e. first object being equal to zero. 1359- MessagePack parser failing to parse the entry data. 1360- MessagePack parser consuming less or requesting greater bytes then described 1361 in the third object for parsing fourth object. I.e. when fourth object 1362 either contains more then one MessagePack object or it does not contain 1363 complete MessagePack object. 1364 1365============================================================================== 1366Standard Paths *standard-path* 1367 1368Nvim stores configuration, data, and logs in standard locations. Plugins are 1369strongly encouraged to follow this pattern also. Use |stdpath()| to get the 1370paths. 1371 1372 *base-directories* *xdg* 1373The "base" (root) directories conform to the XDG Base Directory Specification. 1374https://specifications.freedesktop.org/basedir/latest/ 1375 1376The $XDG_CONFIG_HOME, $XDG_DATA_HOME, $XDG_RUNTIME_DIR, $XDG_STATE_HOME, 1377$XDG_CACHE_HOME, $XDG_CONFIG_DIRS and $XDG_DATA_DIRS environment variables 1378are used if defined, else default values (listed below) are used. 1379 1380Note: In the help these defaults are used as placeholders, e.g. "~/.config" is 1381understood as "$XDG_CONFIG_HOME or ~/.config". 1382 1383CONFIG DIRECTORY (DEFAULT) ~ 1384 *$XDG_CONFIG_HOME* Nvim: stdpath("config") > 1385 Unix: ~/.config ~/.config/nvim 1386 Windows: ~/AppData/Local ~/AppData/Local/nvim 1387 1388DATA DIRECTORY (DEFAULT) ~ 1389 *$XDG_DATA_HOME* Nvim: stdpath("data") > 1390 Unix: ~/.local/share ~/.local/share/nvim 1391 Windows: ~/AppData/Local ~/AppData/Local/nvim-data 1392 1393RUN DIRECTORY (DEFAULT) ~ 1394 *$XDG_RUNTIME_DIR* Nvim: stdpath("run") > 1395 Unix: /tmp/nvim.user/xxx /tmp/nvim.user/xxx 1396 Windows: $TMP/nvim.user/xxx $TMP/nvim.user/xxx 1397 1398STATE DIRECTORY (DEFAULT) ~ 1399 *$XDG_STATE_HOME* Nvim: stdpath("state") > 1400 Unix: ~/.local/state ~/.local/state/nvim 1401 Windows: ~/AppData/Local ~/AppData/Local/nvim-data 1402 1403CACHE DIRECTORY (DEFAULT) ~ 1404 *$XDG_CACHE_HOME* Nvim: stdpath("cache") > 1405 Unix: ~/.cache ~/.cache/nvim 1406 Windows: ~/AppData/Local/Temp ~/AppData/Local/Temp/nvim-data 1407 1408LOG DIRECTORY (DEFAULT) ~ 1409 *$XDG_STATE_HOME*/.../logs Nvim: stdpath("log") > 1410 Unix: Not applicable ~/.local/state/nvim/logs 1411 Windows: Not applicable ~/AppData/Local/nvim-data/logs 1412 1413LOG FILE (DEFAULT) ~ 1414 `$NVIM_LOG_FILE` Nvim: stdpath("log")/nvim.log > 1415 Unix: ~/.local/state/nvim ~/.local/state/nvim/logs/nvim.log 1416 Windows: ~/AppData/Local/nvim-data ~/AppData/Local/nvim-data/logs/nvim.log 1417 1418ADDITIONAL CONFIGS DIRECTORY (DEFAULT) ~ 1419 *$XDG_CONFIG_DIRS* Nvim: stdpath("config_dirs") > 1420 Unix: /etc/xdg/ /etc/xdg/nvim 1421 Windows: Not applicable Not applicable 1422 1423ADDITIONAL DATA DIRECTORY (DEFAULT) ~ 1424 *$XDG_DATA_DIRS* Nvim: stdpath("data_dirs") > 1425 Unix: /usr/local/share /usr/local/share/nvim 1426 /usr/share /usr/share/nvim 1427 Windows: Not applicable Not applicable 1428 1429NVIM_APPNAME *$NVIM_APPNAME* 1430The standard directories can be further configured by the `$NVIM_APPNAME` 1431environment variable. This variable controls the sub-directory that Nvim will 1432read from (and auto-create) in each of the base directories. For example, 1433setting `$NVIM_APPNAME` to "foo" before starting will cause Nvim to look for 1434configuration files in `$XDG_CONFIG_HOME/foo` instead of 1435`$XDG_CONFIG_HOME/nvim`. `$NVIM_APPNAME` must be a name, such as "foo", or a 1436relative path, such as "foo/bar". 1437 1438Note: In the help wherever `$XDG_CONFIG_…/nvim` is mentioned it is understood 1439as `$XDG_CONFIG_…/$NVIM_APPNAME`. 1440 1441 *state-isolation* 1442One use-case for $NVIM_APPNAME is to "isolate" Nvim applications. 1443Alternatively, for true isolation, on Linux you can use cgroups namespaces: > 1444 systemd-run --user -qt -p PrivateUsers=yes -p BindPaths=/home/user/profile_xy:/home/user/.config/nvim nvim 1445< 1446 *stateless* 1447To run Nvim without creating any directories or data files: > 1448 NVIM_LOG_FILE=/dev/null nvim -n -i NONE 1449 1450LOG FILE *log* *$NVIM_LOG_FILE* *E5430* 1451Besides 'debug' and 'verbose', Nvim keeps a general log file for internal 1452debugging, plugins and RPC clients. The log file can be viewed with: > 1453 :log nvim 1454 1455Default location is stdpath("log")/nvim.log ($XDG_STATE_HOME/nvim/logs/nvim.log) 1456unless that path is inaccessible or $NVIM_LOG_FILE was set before |startup|. 1457 1458See |log-files| for details about other log files that can be created by Nvim 1459during runtime or by plugins. 1460 1461 1462 vim:et:tw=78:ts=8:sw=4:ft=help:norl: