starting.txt 66 KB

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