You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1389 lines
64 KiB

  1. *starting.txt* Nvim
  2. VIM REFERENCE MANUAL by Bram Moolenaar
  3. Starting Vim *starting*
  4. Type |gO| to see the table of contents.
  5. ==============================================================================
  6. 1. Vim arguments *vim-arguments*
  7. Most often, Vim is started to edit a single file with the command
  8. nvim filename *-vim*
  9. More generally, Vim is started with:
  10. nvim [option | filename] ..
  11. Option arguments and file name arguments can be mixed, and any number of them
  12. can be given. However, watch out for options that take an argument.
  13. The following items may be used to choose how to start editing:
  14. *-file* *---*
  15. filename One or more file names. The first one will be the current
  16. file and read into the buffer. The cursor will be positioned
  17. on the first line of the buffer.
  18. To avoid a file name starting with a '-' being interpreted as
  19. an option, precede the arglist with "--", e.g.: >
  20. nvim -- -filename
  21. < All arguments after the "--" will be interpreted as file names,
  22. no other options or "+command" argument can follow.
  23. *--*
  24. - Alias for stdin (standard input).
  25. Example: >
  26. echo text | nvim - file
  27. < "text" is read into buffer 1, "file" is opened as buffer 2.
  28. In most cases (except -s, -es, |--embed|, --headless) if stdin
  29. is not a TTY then it is read as text, so "-" is implied: >
  30. echo text | nvim file
  31. < The buffer will be marked modified, because it contains text
  32. that needs to be saved (except for readonly |-R| mode).
  33. To read stdin as Normal commands use |-s| with "-": >
  34. echo "ifoo" | nvim -s -
  35. < To read stdin as Ex commands use |-es| or |-e|: >
  36. echo "echo getpid()" | nvim -e - -V1
  37. < To open a file literally named "-", put it after "--": >
  38. echo foo | nvim -- -
  39. < To read stdin as text with |--headless| use "-".
  40. *-t* *-tag*
  41. -t {tag} A tag. "tag" is looked up in the tags file, the associated
  42. file becomes the current file, and the associated command is
  43. executed. Mostly this is used for C programs, in which case
  44. "tag" often is a function name. The effect is that the file
  45. containing that function becomes the current file and the
  46. cursor is positioned on the start of the function (see
  47. |tags|).
  48. *-q* *-qf*
  49. -q [errorfile] QuickFix mode. The file with the name [errorfile] is read
  50. and the first error is displayed. See |quickfix|.
  51. If [errorfile] is not given, the 'errorfile' option is used
  52. for the file name. See 'errorfile' for the default value.
  53. (nothing) Without one of the four items above, Vim will start editing a
  54. new buffer. It's empty and doesn't have a file name.
  55. *startup-options*
  56. The option arguments may be given in any order. Single-letter options can be
  57. combined after one dash. There can be no option arguments after the "--"
  58. argument.
  59. --help *-h* *--help* *-?*
  60. -?
  61. -h Give usage (help) message and exit.
  62. See |info-message| about capturing the text.
  63. --version *-v* *--version*
  64. -v Print version information and exit. Same output as for
  65. |:version| command.
  66. See |info-message| about capturing the text.
  67. *--clean*
  68. --clean Equivalent to "-u NONE -i NONE":
  69. - Skips initializations from files and environment variables.
  70. - No 'shada' file is read or written.
  71. *--noplugin*
  72. --noplugin Skip loading plugins. Resets the 'loadplugins' option.
  73. Note that the |-u| argument may also disable loading plugins:
  74. argument load vimrc files load plugins ~
  75. (nothing) yes yes
  76. -u NONE no no
  77. -u NORC no yes
  78. --noplugin yes no
  79. --startuptime {fname} *--startuptime*
  80. During startup write timing messages to the file {fname}.
  81. This can be used to find out where time is spent while loading
  82. your |init.vim|, plugins and opening the first file.
  83. When {fname} already exists new messages are appended.
  84. (Only available when compiled with the |+startuptime|
  85. feature).
  86. *-+*
  87. +[num] The cursor will be positioned on line "num" for the first
  88. file being edited. If "num" is missing, the cursor will be
  89. positioned on the last line.
  90. *-+/*
  91. +/{pat} The cursor will be positioned on the first line containing
  92. "pat" in the first file being edited (see |pattern| for the
  93. available search patterns). The search starts at the cursor
  94. position, which can be the first line or the cursor position
  95. last used from |shada|. To force a search from the first
  96. line use "+1 +/pat".
  97. +{command} *-+c* *-c*
  98. -c {command} {command} will be executed after the first file has been
  99. read (and after autocommands and modelines for that file have
  100. been processed). "command" is interpreted as an Ex command.
  101. If the "command" contains spaces, it must be enclosed in
  102. double quotes (this depends on the shell that is used).
  103. Example: >
  104. vim "+set si" main.c
  105. vim "+find stdio.h"
  106. vim -c "set ff=dos" -c wq mine.mak
  107. <
  108. Note: You can use up to 10 "+" or "-c" arguments in a Vim
  109. command. They are executed in the order given. A "-S"
  110. argument counts as a "-c" argument as well.
  111. --cmd {command} *--cmd*
  112. {command} will be executed before processing any vimrc file.
  113. Otherwise it acts like -c {command}. You can use up to 10 of
  114. these commands, independently from "-c" commands.
  115. *-S*
  116. -S {file} The {file} will be sourced after the first file has been read.
  117. This is an easy way to do the equivalent of: >
  118. -c "source {file}"
  119. < It can be mixed with "-c" arguments and repeated like "-c".
  120. The limit of 10 "-c" arguments applies here as well.
  121. {file} cannot start with a "-".
  122. -S Works like "-S Session.vim". Only when used as the last
  123. argument or when another "-" option follows.
  124. -L *-L* *-r*
  125. -r Recovery mode. Without a file name argument, a list of
  126. existing swap files is given. With a file name, a swap file
  127. is read to recover a crashed editing session. See
  128. |crash-recovery|.
  129. *-R*
  130. -R Readonly mode. The 'readonly' option will be set for all the
  131. files being edited. You can still edit the buffer, but will
  132. be prevented from accidentally overwriting a file. If you
  133. forgot that you are in View mode and did make some changes,
  134. you can overwrite a file by adding an exclamation mark to
  135. the Ex command, as in ":w!". The 'readonly' option can be
  136. reset with ":set noro" (see the options chapter, |options|).
  137. Subsequent edits will not be done in readonly mode. Calling
  138. the executable "view" has the same effect as the -R argument.
  139. The 'updatecount' option will be set to 10000, meaning that
  140. the swap file will not be updated automatically very often.
  141. See |-M| for disallowing modifications.
  142. *-m*
  143. -m Modifications not allowed to be written. The 'write' option
  144. will be reset, so that writing files is disabled. However,
  145. the 'write' option can be set to enable writing again.
  146. *-M*
  147. -M Modifications not allowed. The 'modifiable' option will be
  148. reset, so that changes are not allowed. The 'write' option
  149. will be reset, so that writing files is disabled. However,
  150. the 'modifiable' and 'write' options can be set to enable
  151. changes and writing.
  152. *-Z* *restricted-mode* *E145*
  153. -Z Restricted mode. All commands that make use of an external
  154. shell are disabled. This includes suspending with CTRL-Z,
  155. ":sh", filtering, the system() function, backtick expansion,
  156. delete(), rename(), mkdir(), writefile(), libcall(),
  157. jobstart(), etc.
  158. -e *-e* *-E*
  159. -E Start Nvim in Ex mode |gQ|.
  160. If stdin is not a TTY:
  161. -e reads/executes stdin as Ex commands.
  162. -E reads stdin as text (into buffer 1).
  163. -es *-es* *-Es* *-s-ex* *silent-mode*
  164. -Es Silent or batch mode. Special case of |-s| (which takes an
  165. argument while "-es" doesn't). Disables most prompts,
  166. messages, warnings and errors.
  167. -es reads/executes stdin as Ex commands. >
  168. printf "put ='foo'\n%%print\n" | nvim -es
  169. < -Es reads stdin as text (into buffer 1). Use |-c| or "+" to
  170. send commands. >
  171. printf "foo\n" | nvim -Es +"%print"
  172. < Output of these commands is displayed (to stdout):
  173. :print
  174. :list
  175. :number
  176. :set (to display option values)
  177. When 'verbose' is set messages are printed to stderr. >
  178. echo foo | nvim -V1 -es
  179. < User |init.vim| is skipped (unless given with |-u|).
  180. Swap file is skipped (like |-n|).
  181. User |shada| is loaded (unless "-i NONE" is given).
  182. *-b*
  183. -b Binary mode. File I/O will only recognize <NL> to separate
  184. lines. The 'expandtab' option will be reset. The 'textwidth'
  185. option is set to 0. 'modeline' is reset. The 'binary' option
  186. is set. This is done after reading the init.vim/exrc files
  187. but before reading any file in the arglist. See also
  188. |edit-binary|.
  189. *-l*
  190. -l Lisp mode. Sets the 'lisp' and 'showmatch' options on.
  191. *-A*
  192. -A Arabic mode. Sets the 'arabic' option on.
  193. *-H*
  194. -H Hebrew mode. Sets the 'hkmap' and 'rightleft' options on.
  195. *-V* *verbose*
  196. -V[N] Verbose. Sets the 'verbose' option to [N] (default: 10).
  197. Messages will be given for each file that is ":source"d and
  198. for reading or writing a ShaDa file. Can be used to find
  199. out what is happening upon startup and exit.
  200. Example: >
  201. nvim -V8
  202. -V[N]{filename}
  203. Like -V and set 'verbosefile' to {filename}. Messages are not
  204. displayed; instead they are written to the file {filename}.
  205. {filename} must not start with a digit.
  206. Example: >
  207. nvim -V20vimlog
  208. <
  209. *-D*
  210. -D Debugging. Go to debugging mode when executing the first
  211. command from a script. |debug-mode|
  212. {not available when compiled without the |+eval| feature}
  213. *-n*
  214. -n No |swap-file| will be used. Recovery after a crash will be
  215. impossible. Handy if you want to view or edit a file on a
  216. very slow medium (e.g., a floppy).
  217. Can also be done with ":set updatecount=0". You can switch it
  218. on again by setting the 'updatecount' option to some value,
  219. e.g., ":set uc=100".
  220. 'updatecount' is set to 0 AFTER executing commands from a
  221. vimrc file, but before the GUI initializations. Thus it
  222. overrides a setting for 'updatecount' in a vimrc file, but not
  223. in a gvimrc file. See |startup|.
  224. When you want to reduce accesses to the disk (e.g., for a
  225. laptop), don't use "-n", but set 'updatetime' and
  226. 'updatecount' to very big numbers, and type ":preserve" when
  227. you want to save your work. This way you keep the possibility
  228. for crash recovery.
  229. *-o*
  230. -o[N] Open N windows, split horizontally. If [N] is not given,
  231. one window is opened for every file given as argument. If
  232. there is not enough room, only the first few files get a
  233. window. If there are more windows than arguments, the last
  234. few windows will be editing an empty file.
  235. *-O*
  236. -O[N] Open N windows, split vertically. Otherwise it's like -o.
  237. If both the -o and the -O option are given, the last one on
  238. the command line determines how the windows will be split.
  239. *-p*
  240. -p[N] Open N tab pages. If [N] is not given, one tab page is opened
  241. for every file given as argument. The maximum is set with
  242. 'tabpagemax' pages (default 50). If there are more tab pages
  243. than arguments, the last few tab pages will be editing an
  244. empty file. Also see |tabpage|.
  245. *-d*
  246. -d Start in |diff-mode|.
  247. *-u* *E282*
  248. -u {vimrc} The file {vimrc} is read for initializations. Most other
  249. initializations are skipped; see |initialization|.
  250. This can be used to start Vim in a special mode, with special
  251. mappings and settings. A shell alias can be used to make
  252. this easy to use. For example: >
  253. alias vimc vim -u ~/.config/nvim/c_init.vim !*
  254. < Also consider using autocommands; see |autocommand|.
  255. When {vimrc} is "NONE" (all uppercase), all initializations
  256. from files and environment variables are skipped. Plugins and
  257. syntax highlighting are also skipped.
  258. When {vimrc} is "NORC" (all uppercase), this has the same
  259. effect as "NONE", but plugins and syntax highlighting are not
  260. skipped.
  261. *-i*
  262. -i {shada} The file {shada} is used instead of the default ShaDa
  263. file. If the name "NONE" is used (all uppercase), no ShaDa
  264. file is read or written, even if 'shada' is set or when
  265. ":rsh" or ":wsh" are used. See also |shada-file|.
  266. *-s*
  267. -s {scriptin} Read script file {scriptin}, interpreting characters as
  268. Normal-mode input. The same can be done with ":source!": >
  269. :source! {scriptin}
  270. < Reads from stdin if {scriptin} is "-": >
  271. echo "ifoo" | nvim -s -
  272. < If the end of the file is reached before Nvim exits, further
  273. characters are read from the keyboard.
  274. Does not work with |-es|. See also |complex-repeat|.
  275. *-w_nr*
  276. -w {number}
  277. -w{number} Set the 'window' option to {number}.
  278. *-w*
  279. -w {scriptout} All the characters that you type are recorded in the file
  280. "scriptout", until you exit Vim. This is useful if you want
  281. to create a script file to be used with "vim -s" or
  282. ":source!". When the "scriptout" file already exists, new
  283. characters are appended. See also |complex-repeat|.
  284. {scriptout} cannot start with a digit.
  285. *-W*
  286. -W {scriptout} Like -w, but do not append, overwrite an existing file.
  287. *--api-info*
  288. --api-info Print msgpack-encoded |api-metadata| and exit.
  289. *--embed*
  290. --embed Use stdin/stdout as a msgpack-RPC channel, so applications can
  291. embed and control Nvim via the |rpc-api|.
  292. Waits for the client ("embedder") to call |nvim_ui_attach()|
  293. before sourcing startup files and reading buffers, so that UIs
  294. can deterministically handle (display) early messages,
  295. dialogs, etc. The client can do other requests before
  296. `nvim_ui_attach` (e.g. `nvim_get_api_info` for feature-detection).
  297. During this pre-startup phase the user config is of course not
  298. available (similar to `--cmd`).
  299. Embedders _not_ using the UI protocol must pass |--headless|: >
  300. nvim --embed --headless
  301. < Then startup will continue without waiting for `nvim_ui_attach`.
  302. This is equivalent to: >
  303. nvim --headless --cmd "call stdioopen({'rpc': v:true})"
  304. < See also: |ui-startup| |channel-stdio|
  305. *--headless*
  306. --headless Start without UI, and do not wait for `nvim_ui_attach`. The
  307. builtin TUI is not used, so stdio works as an arbitrary
  308. communication channel. |channel-stdio|
  309. Also useful for scripting (tests) to see messages that would
  310. not be printed by |-es|.
  311. To detect if a UI is available, check if |nvim_list_uis()| is
  312. empty during or after |VimEnter|.
  313. To read stdin as text, "-" must be given explicitly:
  314. --headless cannot assume that stdin is just text. >
  315. echo foo | nvim --headless +"%print" +"q!" -
  316. <
  317. See also |--embed|.
  318. See also |-es|, which also disables most messages.
  319. --listen {addr} *--listen*
  320. Start |RPC| server on pipe or TCP address {addr}. Sets the
  321. primary listen address |v:servername| to {addr}. |serverstart()|
  322. ==============================================================================
  323. 2. Initialization *initialization* *startup*
  324. At startup, Vim checks environment variables and files and sets values
  325. accordingly. Vim proceeds in this order:
  326. 1. Set the 'shell' option *SHELL* *COMSPEC*
  327. The environment variable SHELL, if it exists, is used to set the
  328. 'shell' option. On Windows, the COMSPEC variable is used
  329. if SHELL is not set.
  330. 2. Process the arguments
  331. The options and file names from the command that start Vim are
  332. inspected. Buffers are created for all files (but not loaded yet).
  333. The |-V| argument can be used to display or log what happens next,
  334. useful for debugging the initializations.
  335. 3. Execute Ex commands, from environment variables and/or files
  336. An environment variable (e.g. $VIMINIT) is read as one Ex command
  337. line, where multiple commands must be separated with '|' or <NL>.
  338. *config* *init.vim* *vimrc* *exrc*
  339. A file that contains initialization commands is generically called
  340. a "vimrc" or config file. Each line in a vimrc file is executed as an
  341. Ex command line. See also |vimrc-intro| and |base-directories|.
  342. The Nvim config file is named "init.vim", located at:
  343. Unix ~/.config/nvim/init.vim
  344. Windows ~/AppData/Local/nvim/init.vim
  345. Or if |$XDG_CONFIG_HOME| is defined:
  346. $XDG_CONFIG_HOME/nvim/init.vim
  347. If Nvim was started with "-u filename", the file "filename" is used.
  348. All following initializations until 4. are skipped. $MYVIMRC is not
  349. set.
  350. "nvim -u NORC" can be used to skip these initializations without
  351. reading a file. "nvim -u NONE" also skips plugins and syntax
  352. highlighting. |-u|
  353. If Nvim was started with |-es|, all following initializations until 4.
  354. are skipped.
  355. *system-vimrc* *sysinit.vim*
  356. a. The system vimrc file is read for initializations. If
  357. nvim/sysinit.vim file exists in one of $XDG_CONFIG_DIRS, it will be
  358. used. Otherwise, the system vimrc file is used. The path of this file
  359. is shown with the ":version" command. Mostly it's "$VIM/sysinit.vim".
  361. b. Four places are searched for initializations. The first that exists
  362. is used, the others are ignored. The $MYVIMRC environment variable is
  363. set to the file that was first found, unless $MYVIMRC was already set
  364. and when using VIMINIT.
  365. - Environment variable $VIMINIT, used as an Ex command line.
  366. - User |config| file: $XDG_CONFIG_HOME/nvim/init.vim.
  367. - Other config file: {xdg_config_dir}/nvim/init.vim where
  368. {xdg_config_dir} is one of the directories in $XDG_CONFIG_DIRS.
  369. - Environment variable $EXINIT, used as an Ex command line.
  370. c. If the 'exrc' option is on (which is NOT the default), the current
  371. directory is searched for two files. The first that exists is used,
  372. the others are ignored.
  373. - The file ".nvimrc"
  374. - The file ".exrc"
  375. 4. Enable filetype and indent plugins.
  376. This does the same as the commands: >
  377. :runtime! filetype.vim
  378. :runtime! ftplugin.vim
  379. :runtime! indent.vim
  380. < Skipped if ":filetype … off" was called or if the "-u NONE" command
  381. line argument was given.
  382. 5. Enable syntax highlighting.
  383. This does the same as the command: >
  384. :runtime! syntax/syntax.vim
  385. < Skipped if ":syntax off" was called or if the "-u NONE" command
  386. line argument was given.
  387. 6. Load the plugin scripts. *load-plugins*
  388. This does the same as the command: >
  389. :runtime! plugin/**/*.vim
  390. < The result is that all directories in the 'runtimepath' option will be
  391. searched for the "plugin" sub-directory and all files ending in ".vim"
  392. will be sourced (in alphabetical order per directory), also in
  393. subdirectories.
  394. However, directories in 'runtimepath' ending in "after" are skipped
  395. here and only loaded after packages, see below.
  396. Loading plugins won't be done when:
  397. - The 'loadplugins' option was reset in a vimrc file.
  398. - The |--noplugin| command line argument is used.
  399. - The |--clean| command line argument is used.
  400. - The "-u NONE" command line argument is used |-u|.
  401. - When Vim was compiled without the |+eval| feature.
  402. Note that using "-c 'set noloadplugins'" doesn't work, because the
  403. commands from the command line have not been executed yet. You can
  404. use "--cmd 'set noloadplugins'" or "--cmd 'set loadplugins'" |--cmd|.
  405. Packages are loaded. These are plugins, as above, but found in the
  406. "start" directory of each entry in 'packpath'. Every plugin directory
  407. found is added in 'runtimepath' and then the plugins are sourced. See
  408. |packages|.
  409. The plugins scripts are loaded, as above, but now only the directories
  410. ending in "after" are used. Note that 'runtimepath' will have changed
  411. if packages have been found, but that should not add a directory
  412. ending in "after".
  413. 7. Set 'shellpipe' and 'shellredir'
  414. The 'shellpipe' and 'shellredir' options are set according to the
  415. value of the 'shell' option, unless they have been set before.
  416. This means that Vim will figure out the values of 'shellpipe' and
  417. 'shellredir' for you, unless you have set them yourself.
  418. 8. Set 'updatecount' to zero, if "-n" command argument used
  419. 9. Set binary options
  420. If the "-b" flag was given to Vim, the options for binary editing will
  421. be set now. See |-b|.
  422. 10. Read the ShaDa file
  423. See |shada-file|.
  424. 11. Read the quickfix file
  425. If the "-q" flag was given to Vim, the quickfix file is read. If this
  426. fails, Vim exits.
  427. 12. Open all windows
  428. When the |-o| flag was given, windows will be opened (but not
  429. displayed yet).
  430. When the |-p| flag was given, tab pages will be created (but not
  431. displayed yet).
  432. When switching screens, it happens now. Redrawing starts.
  433. If the "-q" flag was given to Vim, the first error is jumped to.
  434. Buffers for all windows will be loaded.
  435. 13. Execute startup commands
  436. If a "-t" flag was given to Vim, the tag is jumped to.
  437. The commands given with the |-c| and |+cmd| arguments are executed.
  438. If the 'insertmode' option is set, Insert mode is entered.
  439. The starting flag is reset, has("vim_starting") will now return zero.
  440. The |v:vim_did_enter| variable is set to 1.
  441. The |VimEnter| autocommands are executed.
  442. Some hints on using initializations ~
  443. Standard setup:
  444. Create a vimrc file to set the default settings and mappings for all your edit
  445. sessions. Put it in a place so that it will be found by 3b:
  446. ~/.config/nvim/init.vim (Unix)
  447. ~/AppData/Local/nvim/init.vim (Win32)
  448. Local setup:
  449. Put all commands that you need for editing a specific directory only into a
  450. vimrc file and place it in that directory under the name ".nvimrc" ("_nvimrc"
  451. for Windows). NOTE: To make Vim look for these special files you
  452. have to turn on the option 'exrc'. See |trojan-horse| too.
  453. System setup:
  454. This only applies if you are managing a Unix system with several users and
  455. want to set the defaults for all users. Create a vimrc file with commands
  456. for default settings and mappings and put it in the place that is given with
  457. the ":version" command. NOTE: System vimrc file needs specific compilation
  458. options (one needs to define SYS_VIMRC_FILE macros). If :version command does
  459. not show anything like this, consider contacting the nvim package maintainer.
  460. Saving the current state of Vim to a file ~
  461. Whenever you have changed values of options or when you have created a
  462. mapping, then you may want to save them in a vimrc file for later use. See
  463. |save-settings| about saving the current state of settings to a file.
  464. Avoiding setup problems for Vi users ~
  465. Vi uses the variable EXINIT and the file "~/.exrc". So if you do not want to
  466. interfere with Vi, then use the variable VIMINIT and the file init.vim
  467. instead.
  468. MS-DOS line separators: ~
  469. On Windows systems Vim assumes that all the vimrc files have <CR> <NL> pairs
  470. as line separators. This will give problems if you have a file with only
  471. <NL>s and have a line like ":map xx yy^M". The trailing ^M will be ignored.
  472. Avoiding trojan horses ~
  473. *trojan-horse*
  474. While reading the "vimrc" or the "exrc" file in the current directory, some
  475. commands can be disabled for security reasons by setting the 'secure' option.
  476. This is always done when executing the command from a tags file. Otherwise it
  477. would be possible that you accidentally use a vimrc or tags file that somebody
  478. else created and contains nasty commands. The disabled commands are the ones
  479. that start a shell, the ones that write to a file, and ":autocmd". The ":map"
  480. commands are echoed, so you can see which keys are being mapped.
  481. If you want Vim to execute all commands in a local vimrc file, you
  482. can reset the 'secure' option in the EXINIT or VIMINIT environment variable or
  483. in the global exrc or vimrc file. This is not possible in vimrc or
  484. exrc in the current directory, for obvious reasons.
  485. On Unix systems, this only happens if you are not the owner of the
  486. vimrc file. Warning: If you unpack an archive that contains a vimrc or exrc
  487. file, it will be owned by you. You won't have the security protection. Check
  488. the vimrc file before you start Vim in that directory, or reset the 'exrc'
  489. option. Some Unix systems allow a user to do "chown" on a file. This makes
  490. it possible for another user to create a nasty vimrc and make you the owner.
  491. Be careful!
  492. When using tag search commands, executing the search command (the last
  493. part of the line in the tags file) is always done in secure mode. This works
  494. just like executing a command from a vimrc/exrc in the current directory.
  495. If Vim startup is slow ~
  496. *slow-start*
  497. If Vim takes a long time to start up, use the |--startuptime| argument to find
  498. out what happens.
  499. If you have 'shada' enabled, the loading of the ShaDa file may take a
  500. while. You can find out if this is the problem by disabling ShaDa for a
  501. moment (use the Vim argument "-i NONE", |-i|). Try reducing the number of
  502. lines stored in a register with ":set shada='20,<50,s10". |shada-file|.
  503. Intro message ~
  504. *:intro*
  505. When Vim starts without a file name, an introductory message is displayed (for
  506. those who don't know what Vim is). It is removed as soon as the display is
  507. redrawn in any way. To see the message again, use the ":intro" command (if
  508. there is not enough room, you will see only part of it).
  509. To avoid the intro message on startup, add the 'I' flag to 'shortmess'.
  510. *info-message*
  511. The |--help| and |--version| arguments cause Nvim to print a message and then
  512. exit. Normally the message is sent to stdout, thus can be redirected to a
  513. file with: >
  514. nvim --help >file
  515. From inside Nvim: >
  516. :read !nvim --help
  517. ==============================================================================
  518. 3. $VIM and $VIMRUNTIME
  519. *$VIM*
  520. The environment variable "$VIM" is used to locate various user files for Nvim,
  521. such as the user startup script |init.vim|. This depends on the system, see
  522. |startup|.
  523. Nvim will try to get the value for $VIM in this order:
  524. 1. Environment variable $VIM, if it is set.
  525. 2. Path derived from the 'helpfile' option, unless it contains some
  526. environment variable too (default is "$VIMRUNTIME/doc/help.txt"). File
  527. name ("help.txt", etc.) is removed. Trailing directory names are removed,
  528. in this order: "doc", "runtime".
  529. 3. Path derived from the location of the `nvim` executable.
  530. 4. Compile-time defined installation directory (see output of ":version").
  531. After doing this once, Nvim sets the $VIM environment variable.
  532. *$VIMRUNTIME*
  533. The environment variable "$VIMRUNTIME" is used to locate various support
  534. files, such as the documentation and syntax-highlighting files. For example,
  535. the main help file is normally "$VIMRUNTIME/doc/help.txt".
  536. Nvim will try to get the value for $VIMRUNTIME in this order:
  537. 1. Environment variable $VIMRUNTIME, if it is set.
  538. 2. Directory path "$VIM/vim{version}", if it exists, where {version} is the
  539. Vim version number without '-' or '.'. For example: "$VIM/vim54".
  540. 3. Directory path "$VIM/runtime", if it exists.
  541. 4. Value of $VIM environment variable. This is for backwards compatibility
  542. with older Vim versions.
  543. 5. If "../share/nvim/runtime" exists relative to |v:progpath|, it is used.
  544. 6. Path derived from the 'helpfile' option (if it doesn't contain '$') with
  545. "doc/help.txt" removed from the end.
  546. After doing this once, Nvim sets the $VIMRUNTIME environment variable.
  547. In case you need the value of $VIMRUNTIME in a shell (e.g., for a script that
  548. greps in the help files) you might be able to use this: >
  549. VIMRUNTIME="$(nvim -e --cmd 'echo $VIMRUNTIME|quit' 2>&1)"
  550. ==============================================================================
  551. 4. Suspending *suspend*
  552. *iconize* *iconise* *CTRL-Z* *v_CTRL-Z*
  553. CTRL-Z Suspend Nvim, like ":stop".
  554. Works in Normal and in Visual mode. In Insert and
  555. Command-line mode, the CTRL-Z is inserted as a normal
  556. character. In Visual mode Nvim goes back to Normal
  557. mode.
  558. :sus[pend][!] or *:sus* *:suspend* *:st* *:stop*
  559. :st[op][!] Suspend Nvim using OS "job control"; it will continue
  560. if you make it the foreground job again. Triggers
  561. |VimSuspend| before suspending and |VimResume| when
  562. resumed.
  563. If "!" is not given and 'autowrite' is set, every
  564. buffer with changes and a file name is written out.
  565. If "!" is given or 'autowrite' is not set, changed
  566. buffers are not written, don't forget to bring Nvim
  567. back to the foreground later!
  568. In the GUI, suspending is implementation-defined.
  569. ==============================================================================
  570. 5. Exiting *exiting*
  571. There are several ways to exit Vim:
  572. - Close the last window with `:quit`. Only when there are no changes.
  573. - Close the last window with `:quit!`. Also when there are changes.
  574. - Close all windows with `:qall`. Only when there are no changes.
  575. - Close all windows with `:qall!`. Also when there are changes.
  576. - Use `:cquit`. Also when there are changes.
  577. When using `:cquit` or when there was an error message Vim exits with exit
  578. code 1. Errors can be avoided by using `:silent!` or with `:catch`.
  579. ==============================================================================
  580. 6. Saving settings *save-settings*
  581. Mostly you will edit your vimrc files manually. This gives you the greatest
  582. flexibility. There are a few commands to generate a vimrc file automatically.
  583. You can use these files as they are, or copy/paste lines to include in another
  584. vimrc file.
  585. *:mk* *:mkexrc*
  586. :mk[exrc] [file] Write current key mappings and changed options to
  587. [file] (default ".exrc" in the current directory),
  588. unless it already exists.
  589. :mk[exrc]! [file] Always write current key mappings and changed
  590. options to [file] (default ".exrc" in the current
  591. directory).
  592. *:mkv* *:mkvimrc*
  593. :mkv[imrc][!] [file] Like ":mkexrc", but the default is ".nvimrc" in the
  594. current directory. The ":version" command is also
  595. written to the file.
  596. These commands will write ":map" and ":set" commands to a file, in such a way
  597. that when these commands are executed, the current key mappings and options
  598. will be set to the same values. The options 'columns', 'endofline',
  599. 'fileformat', 'lines', 'modified', and 'scroll' are not included, because
  600. these are terminal or file dependent.
  601. Note that the options 'binary', 'paste' and 'readonly' are included, this
  602. might not always be what you want.
  603. When special keys are used in mappings, The 'cpoptions' option will be
  604. temporarily set to its Vim default, to avoid the mappings to be
  605. misinterpreted. This makes the file incompatible with Vi, but makes sure it
  606. can be used with different terminals.
  607. Only global mappings are stored, not mappings local to a buffer.
  608. A common method is to use a default |init.vim| file, make some modifications
  609. with ":map" and ":set" commands and write the modified file. First read the
  610. default vimrc in with a command like ":source ~piet/.vimrc.Cprogs", change
  611. the settings and then save them in the current directory with ":mkvimrc!". If
  612. you want to make this file your default |init.vim|, move it to
  613. $XDG_CONFIG_HOME/nvim. You could also use autocommands |autocommand| and/or
  614. modelines |modeline|.
  615. *vimrc-option-example*
  616. If you only want to add a single option setting to your vimrc, you can use
  617. these steps:
  618. 1. Edit your vimrc file with Vim.
  619. 2. Play with the option until it's right. E.g., try out different values for
  620. 'guifont'.
  621. 3. Append a line to set the value of the option, using the expression register
  622. '=' to enter the value. E.g., for the 'guifont' option: >
  623. o:set guifont=<C-R>=&guifont<CR><Esc>
  624. < [<C-R> is a CTRL-R, <CR> is a return, <Esc> is the escape key]
  625. You need to escape special characters, esp. spaces.
  626. ==============================================================================
  627. 7. Views and Sessions *views-sessions*
  628. This is introduced in sections |21.4| and |21.5| of the user manual.
  629. *View* *view-file*
  630. A View is a collection of settings that apply to one window. You can save a
  631. View and when you restore it later, the text is displayed in the same way.
  632. The options and mappings in this window will also be restored, so that you can
  633. continue editing like when the View was saved.
  634. *Session* *session-file*
  635. A Session keeps the Views for all windows, plus the global settings. You can
  636. save a Session and when you restore it later the window layout looks the same.
  637. You can use a Session to quickly switch between different projects,
  638. automatically loading the files you were last working on in that project.
  639. Views and Sessions are a nice addition to ShaDa files, which are used to
  640. remember information for all Views and Sessions together |shada-file|.
  641. You can quickly start editing with a previously saved View or Session with the
  642. |-S| argument: >
  643. vim -S Session.vim
  644. <
  645. *:mks* *:mksession*
  646. :mks[ession][!] [file] Write a Vim script that restores the current editing
  647. session.
  648. When [!] is included an existing file is overwritten.
  649. When [file] is omitted "Session.vim" is used.
  650. The output of ":mksession" is like ":mkvimrc", but additional commands are
  651. added to the file. Which ones depends on the 'sessionoptions' option. The
  652. resulting file, when executed with a ":source" command:
  653. 1. Restores global mappings and options, if 'sessionoptions' contains
  654. "options". Script-local mappings will not be written.
  655. 2. Restores global variables that start with an uppercase letter and contain
  656. at least one lowercase letter, if 'sessionoptions' contains "globals".
  657. 3. Unloads all currently loaded buffers.
  658. 4. Restores the current directory if 'sessionoptions' contains "curdir", or
  659. sets the current directory to where the Session file is if 'sessionoptions'
  660. contains "sesdir".
  661. 5. Restores GUI Vim window position, if 'sessionoptions' contains "winpos".
  662. 6. Restores screen size, if 'sessionoptions' contains "resize".
  663. 7. Reloads the buffer list, with the last cursor positions. If
  664. 'sessionoptions' contains "buffers" then all buffers are restored,
  665. including hidden and unloaded buffers. Otherwise only buffers in windows
  666. are restored.
  667. 8. Restores all windows with the same layout. If 'sessionoptions' contains
  668. "help", help windows are restored. If 'sessionoptions' contains "blank",
  669. windows editing a buffer without a name will be restored.
  670. If 'sessionoptions' contains "winsize" and no (help/blank) windows were
  671. left out, the window sizes are restored (relative to the screen size).
  672. Otherwise, the windows are just given sensible sizes.
  673. 9. Restores the Views for all the windows, as with |:mkview|. But
  674. 'sessionoptions' is used instead of 'viewoptions'.
  675. 10. If a file exists with the same name as the Session file, but ending in
  676. "x.vim" (for eXtra), executes that as well. You can use *x.vim files to
  677. specify additional settings and actions associated with a given Session,
  678. such as creating menu items in the GUI version.
  679. After restoring the Session, the full filename of your current Session is
  680. available in the internal variable |v:this_session|.
  681. An example mapping: >
  682. :nmap <F2> :wa<Bar>exe "mksession! " . v:this_session<CR>:so ~/sessions/
  683. This saves the current Session, and starts off the command to load another.
  684. A session includes all tab pages, unless "tabpages" was removed from
  685. 'sessionoptions'. |tab-page|
  686. The |SessionLoadPost| autocmd event is triggered after a session file is
  687. loaded/sourced.
  688. *SessionLoad-variable*
  689. While the session file is loading the SessionLoad global variable is set to 1.
  690. Plugins can use this to postpone some work until the SessionLoadPost event is
  691. triggered.
  692. *:mkvie* *:mkview*
  693. :mkvie[w][!] [file] Write a Vim script that restores the contents of the
  694. current window.
  695. When [!] is included an existing file is overwritten.
  696. When [file] is omitted or is a number from 1 to 9, a
  697. name is generated and 'viewdir' prepended. When the
  698. last path part of 'viewdir' does not exist, this
  699. directory is created. E.g., when 'viewdir' is
  700. "$VIM/vimfiles/view" then "view" is created in
  701. "$VIM/vimfiles".
  702. An existing file is always overwritten then. Use
  703. |:loadview| to load this view again.
  704. When [file] is the name of a file ('viewdir' is not
  705. used), a command to edit the file is added to the
  706. generated file.
  707. The output of ":mkview" contains these items:
  708. 1. The argument list used in the window. When the global argument list is
  709. used it is reset to the global list.
  710. The index in the argument list is also restored.
  711. 2. The file being edited in the window. If there is no file, the window is
  712. made empty.
  713. 3. Restore mappings, abbreviations and options local to the window if
  714. 'viewoptions' contains "options" or "localoptions". For the options it
  715. restores only values that are local to the current buffer and values local
  716. to the window.
  717. When storing the view as part of a session and "options" is in
  718. 'sessionoptions', global values for local options will be stored too.
  719. 4. Restore folds when using manual folding and 'viewoptions' contains
  720. "folds". Restore manually opened and closed folds.
  721. 5. The scroll position and the cursor position in the file. Doesn't work very
  722. well when there are closed folds.
  723. 6. The local current directory, if it is different from the global current
  724. directory and 'viewoptions' contains "curdir".
  725. Note that Views and Sessions are not perfect:
  726. - They don't restore everything. For example, defined functions, autocommands
  727. and ":syntax on" are not included. Things like register contents and
  728. command line history are in ShaDa, not in Sessions or Views.
  729. - Global option values are only set when they differ from the default value.
  730. When the current value is not the default value, loading a Session will not
  731. set it back to the default value. Local options will be set back to the
  732. default value though.
  733. - Existing mappings will be overwritten without warning. An existing mapping
  734. may cause an error for ambiguity.
  735. - When storing manual folds and when storing manually opened/closed folds,
  736. changes in the file between saving and loading the view will mess it up.
  737. - The Vim script is not very efficient. But still faster than typing the
  738. commands yourself!
  739. *:lo* *:loadview*
  740. :lo[adview] [nr] Load the view for the current file. When [nr] is
  741. omitted, the view stored with ":mkview" is loaded.
  742. When [nr] is specified, the view stored with ":mkview
  743. [nr]" is loaded.
  744. The combination of ":mkview" and ":loadview" can be used to store up to ten
  745. different views of a file. These are remembered in the directory specified
  746. with the 'viewdir' option. The views are stored using the file name. If a
  747. file is renamed or accessed through a (symbolic) link the view will not be
  748. found.
  749. You might want to clean up your 'viewdir' directory now and then.
  750. To automatically save and restore views for *.c files: >
  751. au BufWinLeave *.c mkview
  752. au BufWinEnter *.c silent! loadview
  753. ==============================================================================
  754. 8. The ShaDa file *shada* *shada-file*
  755. If you exit Vim and later start it again, you would normally lose a lot of
  756. information. The ShaDa file can be used to remember that information, which
  757. enables you to continue where you left off. Its name is the abbreviation of
  758. SHAred DAta because it is used for sharing data between Neovim sessions.
  759. This is introduced in section |21.3| of the user manual.
  760. The ShaDa file is used to store:
  761. - The command line history.
  762. - The search string history.
  763. - The input-line history.
  764. - Contents of non-empty registers.
  765. - Marks for several files.
  766. - File marks, pointing to locations in files.
  767. - Last search/substitute pattern (for 'n' and '&').
  768. - The buffer list.
  769. - Global variables.
  770. You could also use a Session file. The difference is that the ShaDa file
  771. does not depend on what you are working on. There normally is only one
  772. ShaDa file. Session files are used to save the state of a specific editing
  773. Session. You could have several Session files, one for each project you are
  774. working on. ShaDa and Session files together can be used to effectively
  775. enter Vim and directly start working in your desired setup. |session-file|
  776. *shada-read*
  777. When Vim is started and the 'shada' option is non-empty, the contents of
  778. the ShaDa file are read and the info can be used in the appropriate places.
  779. The |v:oldfiles| variable is filled. The marks are not read in at startup
  780. (but file marks are). See |initialization| for how to set the 'shada'
  781. option upon startup.
  782. *shada-write*
  783. When Vim exits and 'shada' is non-empty, the info is stored in the ShaDa file
  784. (it's actually merged with the existing one, if one exists |shada-merging|).
  785. The 'shada' option is a string containing information about what info should
  786. be stored, and contains limits on how much should be stored (see 'shada').
  787. Notes for Unix:
  788. - The file protection for the ShaDa file will be set to prevent other users
  789. from being able to read it, because it may contain any text or commands that
  790. you have worked with.
  791. - If you want to share the ShaDa file with other users (e.g. when you "su"
  792. to another user), you can make the file writable for the group or everybody.
  793. Vim will preserve this when writing new ShaDa files. Be careful, don't
  794. allow just anybody to read and write your ShaDa file!
  795. - Vim will not overwrite a ShaDa file that is not writable by the current
  796. "real" user. This helps for when you did "su" to become root, but your
  797. $HOME is still set to a normal user's home directory. Otherwise Vim would
  798. create a ShaDa file owned by root that nobody else can read.
  799. - The ShaDa file cannot be a symbolic link. This is to avoid security
  800. issues.
  801. Marks are stored for each file separately. When a file is read and 'shada'
  802. is non-empty, the marks for that file are read from the ShaDa file. NOTE:
  803. The marks are only written when exiting Vim, which is fine because marks are
  804. remembered for all the files you have opened in the current editing session,
  805. unless ":bdel" is used. If you want to save the marks for a file that you are
  806. about to abandon with ":bdel", use ":wsh". The '[' and ']' marks are not
  807. stored, but the '"' mark is. The '"' mark is very useful for jumping to the
  808. cursor position when the file was last exited. No marks are saved for files
  809. that start with any string given with the "r" flag in 'shada'. This can be
  810. used to avoid saving marks for files on removable media (for Windows you would
  811. use "ra:,rb:".
  812. The |v:oldfiles| variable is filled with the file names that the ShaDa file
  813. has marks for.
  814. *shada-file-marks*
  815. Uppercase marks ('A to 'Z) are stored when writing the ShaDa file. The
  816. numbered marks ('0 to '9) are a bit special. When the ShaDa file is written
  817. (when exiting or with the |:wshada| command), '0 is set to the current cursor
  818. position and file. The old '0 is moved to '1, '1 to '2, etc. This
  819. resembles what happens with the "1 to "9 delete registers. If the current
  820. cursor position is already present in '0 to '9, it is moved to '0, to avoid
  821. having the same position twice. The result is that with "'0", you can jump
  822. back to the file and line where you exited Vim. To do that right away, try
  823. using this command: >
  824. vim -c "normal '0"
  825. In a csh compatible shell you could make an alias for it: >
  826. alias lvim vim -c '"'normal "'"0'"'
  827. For a bash-like shell: >
  828. alias lvim='vim -c "normal '\''0"'
  829. Use the "r" flag in 'shada' to specify for which files no marks should be
  830. remembered.
  831. MERGING *shada-merging*
  832. When writing ShaDa files with |:wshada| without bang or at regular exit
  833. information in the existing ShaDa file is merged with information from current
  834. Neovim instance. For this purpose ShaDa files store timestamps associated
  835. with ShaDa entries. Specifically the following is being done:
  836. 1. History lines are merged, ordered by timestamp. Maximum amount of items in
  837. ShaDa file is defined by 'shada' option (|shada-/|, |shada-:|, |shada-@|,
  838. etc: one suboption for each character that represents history name
  839. (|:history|)).
  840. 2. Local marks and changes for files that were not opened by Neovim are copied
  841. to new ShaDa file. Marks for files that were opened by Neovim are merged,
  842. changes to files opened by Neovim are ignored. |shada-'|
  843. 3. Jump list is merged: jumps are ordered by timestamp, identical jumps
  844. (identical position AND timestamp) are squashed.
  845. 4. Search patterns and substitute strings are not merged: search pattern or
  846. substitute string which has greatest timestamp will be the only one copied
  847. to ShaDa file.
  848. 5. For each register entity with greatest timestamp is the only saved.
  849. |shada-<|
  850. 6. All saved variables are saved from current Neovim instance. Additionally
  851. existing variable values are copied, meaning that the only way to remove
  852. variable from a ShaDa file is either removing it by hand or disabling
  853. writing variables completely. |shada-!|
  854. 7. For each global mark entity with greatest timestamp is the only saved.
  855. 8. Buffer list and header are the only entries which are not merged in any
  856. fashion: the only header and buffer list present are the ones from the
  857. Neovim instance which was last writing the file. |shada-%|
  858. COMPATIBILITY *shada-compatibility*
  859. ShaDa files are forward and backward compatible. This means that
  860. 1. Entries which have unknown type (i.e. that hold unidentified data) are
  861. ignored when reading and blindly copied when writing.
  862. 2. Register entries with unknown register name are ignored when reading and
  863. blindly copied when writing. Limitation: only registers that use name with
  864. code in interval [1, 255] are supported. |registers|
  865. 3. Register entries with unknown register type are ignored when reading and
  866. merged as usual when writing. |getregtype()|
  867. 4. Local and global mark entries with unknown mark names are ignored when
  868. reading. When writing global mark entries are blindly copied and local mark
  869. entries are also blindly copied, but only if file they are attached to fits
  870. in the |shada-'| limit. Unknown local mark entry's timestamp is also taken
  871. into account when calculating which files exactly should fit into this
  872. limit. Limitation: only marks that use name with code in interval [1, 255]
  873. are supported. |mark-motions|
  874. 5. History entries with unknown history type are ignored when reading and
  875. blindly copied when writing. Limitation: there can be only up to 256
  876. history types. |history|
  877. 6. Unknown keys found in register, local mark, global mark, change, jump and
  878. search pattern entries are saved internally and dumped when writing.
  879. Entries created during Neovim session never have such additions.
  880. 7. Additional elements found in replacement string and history entries are
  881. saved internally and dumped. Entries created during Neovim session never
  882. have such additions.
  883. 8. Additional elements found in variable entries are simply ignored when
  884. reading. When writing new variables they will be preserved during merging,
  885. but that's all. Variable values dumped from current Neovim session never
  886. have additional elements, even if variables themselves were obtained by
  887. reading ShaDa files.
  888. "Blindly" here means that there will be no attempts to somehow merge them,
  889. even if other entries (with known name/type/etc) are merged. |shada-merging|
  890. SHADA FILE NAME *shada-file-name*
  891. - Default name of the |shada| file is:
  892. Unix: "$XDG_DATA_HOME/nvim/shada/main.shada"
  893. Windows: "$XDG_DATA_HOME/nvim-data/shada/main.shada"
  894. See also |base-directories|.
  895. - To choose a different file name you can use:
  896. - The "n" flag in the 'shada' option.
  897. - The |-i| startup argument. "NONE" means no shada file is ever read or
  898. written. Also not for the commands below!
  899. - The 'shadafile' option. The value from the "-i" argument (if any) is
  900. stored in the 'shadafile' option.
  901. - For the commands below, another file name can be given, overriding the
  902. default and the name given with 'shada' or "-i" (unless it's NONE).
  903. MANUALLY READING AND WRITING *shada-read-write*
  904. Two commands can be used to read and write the ShaDa file manually. This
  905. can be used to exchange registers between two running Vim programs: First
  906. type ":wsh" in one and then ":rsh" in the other. Note that if the register
  907. already contained something, then ":rsh!" would be required. Also note
  908. however that this means everything will be overwritten with information from
  909. the first Vim, including the command line history, etc.
  910. The ShaDa file itself can be edited by hand too, although we suggest you
  911. start with an existing one to get the format right. You need to understand
  912. MessagePack (or, more likely, find software that is able to use it) format to
  913. do this. This can be useful in order to create a second file, say
  914. "~/.my.shada" which could contain certain settings that you always want when
  915. you first start Neovim. For example, you can preload registers with
  916. particular data, or put certain commands in the command line history. A line
  917. in your |init.vim| file like >
  918. :rshada! ~/.my.shada
  919. can be used to load this information. You could even have different ShaDa
  920. files for different types of files (e.g., C code) and load them based on the
  921. file name, using the ":autocmd" command (see |:autocmd|). More information on
  922. ShaDa file format is contained in |shada-format| section.
  923. *E136* *E929* *shada-error-handling*
  924. Some errors make Neovim leave temporary file named `{basename}.tmp.X` (X is
  925. any free letter from `a` to `z`) while normally it will create this file,
  926. write to it and then rename `{basename}.tmp.X` to `{basename}`. Such errors
  927. include:
  928. - Errors which make Neovim think that read file is not a ShaDa file at all:
  929. non-ShaDa files are not overwritten for safety reasons to avoid accidentally
  930. destroying an unrelated file. This could happen e.g. when typing "nvim -i
  931. file" in place of "nvim -R file" (yes, somebody did that at least with Vim).
  932. Such errors are listed at |shada-critical-contents-errors|.
  933. - If writing to the temporary file failed: e.g. because of the insufficient
  934. space left.
  935. - If renaming file failed: e.g. because of insufficient permissions.
  936. - If target ShaDa file has different from the Neovim instance's owners (user
  937. and group) and changing them failed. Unix-specific, applies only when
  938. Neovim was launched from root.
  939. Do not forget to remove the temporary file or replace the target file with
  940. temporary one after getting one of the above errors or all attempts to create
  941. a ShaDa file may fail with |E929|. If you got one of them when using
  942. |:wshada| (and not when exiting Neovim: i.e. when you have Neovim session
  943. running) you have additional options:
  944. - First thing which you should consider if you got any error, except failure
  945. to write to the temporary file: remove existing file and replace it with the
  946. temporary file. Do it even if you have running Neovim instance.
  947. - Fix the permissions and/or file ownership, free some space and attempt to
  948. write again. Do not remove the existing file.
  949. - Use |:wshada| with bang. Does not help in case of permission error. If
  950. target file was actually the ShaDa file some information may be lost in this
  951. case. To make the matters slightly better use |:rshada| prior to writing,
  952. but this still will loose buffer-local marks and change list entries for any
  953. file which is not opened in the current Neovim instance.
  954. - Remove the target file from shell and use |:wshada|. Consequences are not
  955. different from using |:wshada| with bang, but "rm -f" works in some cases
  956. when you don't have write permissions.
  957. *:rsh* *:rshada* *E886*
  958. :rsh[ada][!] [file] Read from ShaDa file [file] (default: see above).
  959. If [!] is given, then any information that is
  960. already set (registers, marks, |v:oldfiles|, etc.)
  961. will be overwritten.
  962. *:wsh* *:wshada* *E137*
  963. :wsh[ada][!] [file] Write to ShaDa file [file] (default: see above).
  964. The information in the file is first read in to make
  965. a merge between old and new info. When [!] is used,
  966. the old information is not read first, only the
  967. internal info is written (also disables safety checks
  968. described in |shada-error-handling|). If 'shada' is
  969. empty, marks for up to 100 files will be written.
  970. When you get error "E929: All .tmp.X files exist,
  971. cannot write ShaDa file!" check that no old temp files
  972. were left behind (e.g.
  973. ~/.local/share/nvim/shada/main.shada.tmp*).
  974. Note: Executing :wshada will reset all |'quote| marks.
  975. *:o* *:ol* *:oldfiles*
  976. :o[ldfiles] List the files that have marks stored in the ShaDa
  977. file. This list is read on startup and only changes
  978. afterwards with `:rshada!`. Also see |v:oldfiles|.
  979. The number can be used with |c_#<|.
  980. The output can be filtered with |:filter|, e.g.: >
  981. filter /\.vim/ oldfiles
  982. < The filtering happens on the file name.
  983. :bro[wse] o[ldfiles][!]
  984. List file names as with |:oldfiles|, and then prompt
  985. for a number. When the number is valid that file from
  986. the list is edited.
  987. If you get the |press-enter| prompt you can press "q"
  988. and still get the prompt to enter a file number.
  989. Use ! to abandon a modified buffer. |abandon|
  990. SHADA FILE FORMAT *shada-format*
  991. ShaDa files are concats of MessagePack entries. Each entry is a concat of
  992. exactly four MessagePack objects:
  993. 1. First goes type of the entry. Object type must be an unsigned integer.
  994. Object type must not be equal to zero.
  995. 2. Second goes entry timestamp. It must also be an unsigned integer.
  996. 3. Third goes the length of the fourth entry. Unsigned integer as well, used
  997. for fast skipping without parsing.
  998. 4. Fourth is actual entry data. All currently used ShaDa entries use
  999. containers to hold data: either map or array. All string values in those
  1000. containers are either binary (applies to filenames) or UTF-8, yet parser
  1001. needs to expect that invalid bytes may be present in a UTF-8 string.
  1002. Exact format depends on the entry type:
  1003. Entry type (name) Entry data ~
  1004. 1 (Header) Map containing data that describes the generator
  1005. instance that wrote this ShaDa file. It is ignored
  1006. when reading ShaDa files. Contains the following data:
  1007. Key Data ~
  1008. generator Binary, software used to generate ShaDa
  1009. file. Is equal to "nvim" when ShaDa file was
  1010. written by Neovim.
  1011. version Binary, generator version.
  1012. encoding Binary, effective 'encoding' value.
  1013. max_kbyte Integer, effective |shada-s| limit value.
  1014. pid Integer, instance process ID.
  1015. * It is allowed to have any number of
  1016. additional keys with any data.
  1017. 2 (SearchPattern) Map containing data describing last used search or
  1018. substitute pattern. Normally ShaDa file contains two
  1019. such entries: one with "ss" key set to true (describes
  1020. substitute pattern, see |:substitute|), and one set to
  1021. false (describes search pattern, see
  1022. |search-commands|). "su" key should be true on one of
  1023. the entries. If key value is equal to default then it
  1024. is normally not present. Keys:
  1025. Key Type Default Description ~
  1026. sm Boolean true Effective 'magic' value.
  1027. sc Boolean false Effective 'smartcase' value.
  1028. sl Boolean true True if search pattern comes
  1029. with a line offset. See
  1030. |search-offset|.
  1031. se Boolean false True if |search-offset|
  1032. requested to place cursor at
  1033. (relative to) the end of the
  1034. pattern.
  1035. so Integer 0 Offset value. |search-offset|
  1036. su Boolean false True if current entry was the
  1037. last used search pattern.
  1038. ss Boolean false True if current entry describes
  1039. |:substitute| pattern.
  1040. sh Boolean false True if |v:hlsearch| is on.
  1041. With |shada-h| or 'nohlsearch'
  1042. this key is always false.
  1043. sp Binary N/A Actual pattern. Required.
  1044. sb Boolean false True if search direction is
  1045. backward.
  1046. * any none Other keys are allowed for
  1047. compatibility reasons, see
  1048. |shada-compatibility|.
  1049. 3 (SubString) Array containing last |:substitute| replacement string.
  1050. Contains single entry: binary, replacement string used.
  1051. More entries are allowed for compatibility reasons, see
  1052. |shada-compatibility|.
  1053. 4 (HistoryEntry) Array containing one entry from history. Should have
  1054. two or three entries. First one is history type
  1055. (unsigned integer), second is history line (binary),
  1056. third is the separator character (unsigned integer,
  1057. must be in interval [0, 255]). Third item is only
  1058. valid for search history. Possible history types are
  1059. listed in |hist-names|, here are the corresponding
  1060. numbers: 0 - cmd, 1 - search, 2 - expr, 3 - input,
  1061. 4 - debug.
  1062. 5 (Register) Map describing one register (|registers|). If key
  1063. value is equal to default then it is normally not
  1064. present. Keys:
  1065. Key Type Def Description ~
  1066. rt UInteger 0 Register type:
  1067. No Description ~
  1068. 0 |characterwise-register|
  1069. 1 |linewise-register|
  1070. 2 |blockwise-register|
  1071. rw UInteger 0 Register width. Only valid
  1072. for |blockwise-register|s.
  1073. rc Array of binary N/A Register contents. Each
  1074. entry in the array
  1075. represents its own line.
  1076. NUL characters inside the
  1077. line should be represented
  1078. as NL according to
  1079. |NL-used-for-Nul|.
  1080. ru Boolean false Unnamed register. Whether
  1081. the unnamed register had
  1082. pointed to this register.
  1083. n UInteger N/A Register name: character
  1084. code in range [1, 255].
  1085. Example: |quote0| register
  1086. has name 48 (ASCII code for
  1087. zero character).
  1088. * any none Other keys are allowed
  1089. for compatibility reasons,
  1090. see |shada-compatibility|.
  1091. 6 (Variable) Array containing two items: variable name (binary) and
  1092. variable value (any object). Values are converted
  1093. using the same code |msgpackparse()| uses when reading,
  1094. |msgpackdump()| when writing, so there may appear
  1095. |msgpack-special-dict|s. If there are more then two
  1096. entries then the rest are ignored
  1097. (|shada-compatibility|).
  1098. 7 (GlobalMark)
  1099. 8 (Jump)
  1100. 10 (LocalMark)
  1101. 11 (Change) Map containing some position description:
  1102. Entry Position ~
  1103. GlobaMark Global mark position. |'A|
  1104. LocalMark Local mark position. |'a|
  1105. Jump One position from the |jumplist|.
  1106. Change One position from the |changelist|.
  1107. Data contained in the map:
  1108. Key Type Default Description ~
  1109. l UInteger 1 Position line number. Must be
  1110. greater then zero.
  1111. c UInteger 0 Position column number.
  1112. n UInteger 34 ('"') Mark name. Only valid for
  1113. GlobalMark and LocalMark
  1114. entries.
  1115. f Binary N/A File name. Required.
  1116. * any none Other keys are allowed for
  1117. compatibility reasons, see
  1118. |shada-compatibility|.
  1119. 9 (BufferList) Array containing maps. Each map in the array
  1120. represents one buffer. Possible keys:
  1121. Key Type Default Description ~
  1122. l UInteger 1 Position line number. Must be
  1123. greater then zero.
  1124. c UInteger 0 Position column number.
  1125. f Binary N/A File name. Required.
  1126. * any none Other keys are allowed for
  1127. compatibility reasons, see
  1128. |shada-compatibility|.
  1129. * (Unknown) Any other entry type is allowed for compatibility
  1130. reasons, see |shada-compatibility|.
  1131. *E575* *E576*
  1132. Errors in ShaDa file may have two types: E575 used for all “logical” errors
  1133. and E576 used for all “critical” errors. Critical errors trigger behaviour
  1134. described in |shada-error-handling| when writing and skipping the rest of the
  1135. file when reading and include:
  1136. *shada-critical-contents-errors*
  1137. - Any of first three MessagePack objects being not an unsigned integer.
  1138. - Third object requesting amount of bytes greater then bytes left in the ShaDa
  1139. file.
  1140. - Entry with zero type. I.e. first object being equal to zero.
  1141. - MessagePack parser failing to parse the entry data.
  1142. - MessagePack parser consuming less or requesting greater bytes then described
  1143. in the third object for parsing fourth object. I.e. when fourth object
  1144. either contains more then one MessagePack object or it does not contain
  1145. complete MessagePack object.
  1146. ==============================================================================
  1147. 9. Standard Paths *standard-path*
  1148. Nvim stores configuration and data in standard locations. Plugins are strongly
  1149. encouraged to follow this pattern also. Use |stdpath()| to get the paths.
  1150. *base-directories* *xdg*
  1151. The "base" (root) directories conform to the XDG Base Directory Specification.
  1153. The $XDG_CONFIG_HOME and $XDG_DATA_HOME environment variables are used if they
  1154. exist, otherwise default values (listed below) are used.
  1156. *$XDG_CONFIG_HOME* Nvim: stdpath("config")
  1157. Unix: ~/.config ~/.config/nvim
  1158. Windows: ~/AppData/Local ~/AppData/Local/nvim
  1160. *$XDG_DATA_HOME* Nvim: stdpath("data")
  1161. Unix: ~/.local/share ~/.local/share/nvim
  1162. Windows: ~/AppData/Local ~/AppData/Local/nvim-data
  1163. Note: Throughout the user manual these defaults are used as placeholders, e.g.
  1164. "~/.config" is understood to mean "$XDG_CONFIG_HOME or ~/.config".
  1166. Besides 'debug' and 'verbose', Nvim keeps a general log file for internal
  1167. debugging, plugins and RPC clients. >
  1168. :echo $NVIM_LOG_FILE
  1169. Usually the file is ~/.local/share/nvim/log unless that path is inaccessible
  1170. or if $NVIM_LOG_FILE was set before |startup|.
  1171. vim:noet:tw=78:ts=8:ft=help:norl: