starting.txt 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708
  1. *starting.txt* For Vim version 9.0. Last change: 2022 Nov 30
  2. VIM REFERENCE MANUAL by Bram Moolenaar
  3. Starting Vim *starting*
  4. 1. Vim arguments |vim-arguments|
  5. 2. Vim on the Amiga |starting-amiga|
  6. 3. Running eVim |evim-keys|
  7. 4. Initialization |initialization|
  8. 5. $VIM and $VIMRUNTIME |$VIM|
  9. 6. Suspending |suspend|
  10. 7. Exiting |exiting|
  11. 8. Saving settings |save-settings|
  12. 9. Views and Sessions |views-sessions|
  13. 10. The viminfo file |viminfo-file|
  14. ==============================================================================
  15. 1. Vim arguments *vim-arguments*
  16. Most often, Vim is started to edit a single file with the command
  17. vim filename *-vim*
  18. More generally, Vim is started with:
  19. vim [option | filename] ..
  20. Option arguments and file name arguments can be mixed, and any number of them
  21. can be given. However, watch out for options that take an argument.
  22. For compatibility with various Vi versions, see |cmdline-arguments|.
  23. Exactly one out of the following five items may be used to choose how to
  24. start editing:
  25. *-file* *---*
  26. filename One or more file names. The first one will be the current
  27. file and read into the buffer. The cursor will be positioned
  28. on the first line of the buffer.
  29. To avoid a file name starting with a '-' being interpreted as
  30. an option, precede the arglist with "--", e.g.: >
  31. vim -- -filename
  32. < All arguments after the "--" will be interpreted as file names,
  33. no other options or "+command" argument can follow.
  34. For behavior of quotes on MS-Windows, see |win32-quotes|.
  35. *--*
  36. - This argument can mean two things, depending on whether Ex
  37. mode is to be used.
  38. Starting in Normal mode: >
  39. vim -
  40. ex -v -
  41. < Start editing a new buffer, which is filled with text
  42. that is read from stdin. The commands that would normally be
  43. read from stdin will now be read from stderr. Example: >
  44. find . -name "*.c" -print | vim -
  45. < The buffer will be marked as modified, so that you are
  46. reminded to save the text when trying to exit. If you don't
  47. like that, put this these lines in your vimrc: >
  48. " Don't set 'modified' when reading from stdin
  49. au StdinReadPost * set nomodified
  50. <
  51. Starting in Ex mode: >
  52. ex -
  53. vim -e -
  54. exim -
  55. vim -E
  56. < Start editing in silent mode. See |-s-ex|.
  57. *-t* *-tag*
  58. -t {tag} A tag. "tag" is looked up in the tags file, the associated
  59. file becomes the current file, and the associated command is
  60. executed. Mostly this is used for C programs, in which case
  61. "tag" often is a function name. The effect is that the file
  62. containing that function becomes the current file and the
  63. cursor is positioned on the start of the function (see
  64. |tags|).
  65. *-q* *-qf*
  66. -q [errorfile] QuickFix mode. The file with the name [errorfile] is read
  67. and the first error is displayed. See |quickfix|.
  68. If [errorfile] is not given, the 'errorfile' option is used
  69. for the file name. See 'errorfile' for the default value.
  70. (nothing) Without one of the four items above, Vim will start editing a
  71. new buffer. It's empty and doesn't have a file name.
  72. The startup mode can be changed by using another name instead of "vim", which
  73. is equal to giving options:
  74. ex vim -e Start in Ex mode (see |Ex-mode|). *ex*
  75. exim vim -E Start in improved Ex mode (see |Ex-mode|). *exim*
  76. (normally not installed)
  77. view vim -R Start in read-only mode (see |-R|). *view*
  78. gvim vim -g Start the GUI (see |gui|). *gvim*
  79. gex vim -eg Start the GUI in Ex mode. *gex*
  80. gview vim -Rg Start the GUI in read-only mode. *gview*
  81. rvim vim -Z Like "vim", but in restricted mode (see |-Z|) *rvim*
  82. rview vim -RZ Like "view", but in restricted mode. *rview*
  83. rgvim vim -gZ Like "gvim", but in restricted mode. *rgvim*
  84. rgview vim -RgZ Like "gview", but in restricted mode. *rgview*
  85. evim vim -y Easy Vim: set 'insertmode' (see |-y|) *evim*
  86. eview vim -yR Like "evim" in read-only mode *eview*
  87. vimdiff vim -d Start in diff mode |diff-mode|
  88. gvimdiff vim -gd Start in diff mode |diff-mode|
  89. Additional characters may follow, they are ignored. For example, you can have
  90. "gvim-8" to start the GUI. You must have an executable by that name then, of
  91. course.
  92. On Unix, you would normally have one executable called Vim, and links from the
  93. different startup-names to that executable. If your system does not support
  94. links and you do not want to have several copies of the executable, you could
  95. use an alias instead. For example: >
  96. alias view vim -R
  97. alias gvim vim -g
  98. <
  99. *startup-options*
  100. The option arguments may be given in any order. Single-letter options can be
  101. combined after one dash. There can be no option arguments after the "--"
  102. argument.
  103. On VMS all option arguments are assumed to be lowercase, unless preceded with
  104. a slash. Thus "-R" means recovery and "-/R" readonly.
  105. --help *-h* *--help* *-?*
  106. -?
  107. -h Give usage (help) message and exit.
  108. See |info-message| about capturing the text.
  109. *--version*
  110. --version Print version information and exit. Same output as for
  111. |:version| command.
  112. See |info-message| about capturing the text.
  113. *--noplugin*
  114. --noplugin Skip loading plugins. Resets the 'loadplugins' option.
  115. Note that the |-u| argument may also disable loading plugins:
  116. argument load: vimrc files plugins defaults.vim ~
  117. (nothing) yes yes yes
  118. -u NONE no no no
  119. -u DEFAULTS no no yes
  120. -u NORC no yes no
  121. --noplugin yes no yes
  122. --startuptime {fname} *--startuptime*
  123. During startup write timing messages to the file {fname}.
  124. This can be used to find out where time is spent while loading
  125. your .vimrc, plugins and opening the first file.
  126. When {fname} already exists new messages are appended.
  127. {only available when compiled with the |+startuptime|
  128. feature}
  129. *--literal*
  130. --literal Take file names literally, don't expand wildcards. Not needed
  131. for Unix, because Vim always takes file names literally (the
  132. shell expands wildcards).
  133. Applies to all the names, also the ones that come before this
  134. argument.
  135. *-+*
  136. +[num] The cursor will be positioned on line "num" for the first
  137. file being edited. If "num" is missing, the cursor will be
  138. positioned on the last line.
  139. *-+/*
  140. +/{pat} The cursor will be positioned on the first line containing
  141. "pat" in the first file being edited (see |pattern| for the
  142. available search patterns). The search starts at the cursor
  143. position, which can be the first line or the cursor position
  144. last used from |viminfo|. To force a search from the first
  145. line use "+1 +/pat".
  146. +{command} *-+c* *-c*
  147. -c {command} {command} will be executed after the first file has been
  148. read (and after autocommands and modelines for that file have
  149. been processed). "command" is interpreted as an Ex command.
  150. If the "command" contains spaces, it must be enclosed in
  151. double quotes (this depends on the shell that is used).
  152. Example: >
  153. vim "+set si" main.c
  154. vim "+find stdio.h"
  155. vim -c "set ff=dos" -c wq mine.mak
  156. <
  157. Note: You can use up to 10 "+" or "-c" arguments in a Vim
  158. command. They are executed in the order given. A "-S"
  159. argument counts as a "-c" argument as well.
  160. --cmd {command} *--cmd*
  161. {command} will be executed before processing any vimrc file.
  162. Otherwise it acts like -c {command}. You can use up to 10 of
  163. these commands, independently from "-c" commands.
  164. *-S*
  165. -S {file} The {file} will be sourced after the first file has been read.
  166. This is an easy way to do the equivalent of: >
  167. -c "source {file}"
  168. < It can be mixed with "-c" arguments and repeated like "-c".
  169. The limit of 10 "-c" arguments applies here as well.
  170. {file} cannot start with a "-".
  171. Do not use this for running a script to do some work and exit
  172. Vim, you won't see error messages. Use |-u| instead.
  173. -S Works like "-S Session.vim". Only when used as the last
  174. argument or when another "-" option follows.
  175. *-r*
  176. -r Recovery mode. Without a file name argument, a list of
  177. existing swap files is given. With a file name, a swap file
  178. is read to recover a crashed editing session. See
  179. |crash-recovery|.
  180. *-L*
  181. -L Same as -r.
  182. *-R*
  183. -R Readonly mode. The 'readonly' option will be set for all the
  184. files being edited. You can still edit the buffer, but will
  185. be prevented from accidentally overwriting a file. If you
  186. forgot that you are in View mode and did make some changes,
  187. you can overwrite a file by adding an exclamation mark to
  188. the Ex command, as in ":w!". The 'readonly' option can be
  189. reset with ":set noro" (see the options chapter, |options|).
  190. Subsequent edits will not be done in readonly mode. Calling
  191. the executable "view" has the same effect as the -R argument.
  192. The 'updatecount' option will be set to 10000, meaning that
  193. the swap file will not be updated automatically very often.
  194. See |-M| for disallowing modifications.
  195. *-m*
  196. -m Modifications not allowed to be written. The 'write' option
  197. will be reset, so that writing files is disabled. However,
  198. the 'write' option can be set to enable writing again.
  199. *-M*
  200. -M Modifications not allowed. The 'modifiable' option will be
  201. reset, so that changes are not allowed. The 'write' option
  202. will be reset, so that writing files is disabled. However,
  203. the 'modifiable' and 'write' options can be set to enable
  204. changes and writing.
  205. *-Z* *restricted-mode* *E145* *E981*
  206. -Z Restricted mode. All commands that make use of an external
  207. shell are disabled. This includes suspending with CTRL-Z,
  208. ":sh", filtering, the system() function, backtick expansion
  209. and libcall().
  210. Also disallowed are delete(), rename(), mkdir(), job_start(),
  211. etc.
  212. Interfaces, such as Python, Ruby and Lua, are also disabled,
  213. since they could be used to execute shell commands. Perl uses
  214. the Safe module.
  215. For Unix restricted mode is used when the last part of $SHELL
  216. is "nologin" or "false".
  217. Note that the user may still find a loophole to execute a
  218. shell command, it has only been made difficult.
  219. *-g*
  220. -g Start Vim in GUI mode. See |gui|. For the opposite see |-v|.
  221. *-v*
  222. -v Start Ex in Vi mode. Only makes a difference when the
  223. executable is called "ex" or "gvim". For gvim the GUI is not
  224. started if possible.
  225. *-e*
  226. -e Start Vim in Ex mode, see |Ex-mode|. Only makes a difference
  227. when the executable is not called "ex".
  228. *-E*
  229. -E Start Vim in improved Ex mode |gQ|. Only makes a difference
  230. when the executable is not called "exim".
  231. *-s-ex*
  232. -s Silent or batch mode. Only when Vim was started as "ex" or
  233. when preceded with the "-e" argument. Otherwise see |-s|,
  234. which does take an argument while this use of "-s" doesn't.
  235. To be used when Vim is used to execute Ex commands from a file
  236. instead of a terminal. Switches off most prompts and
  237. informative messages. Also warnings and error messages.
  238. The output of these commands is displayed (to stdout):
  239. :print
  240. :list
  241. :number
  242. :set to display option values.
  243. When 'verbose' is non-zero messages are printed (for
  244. debugging, to stderr).
  245. 'term' and $TERM are not used.
  246. If Vim appears to be stuck try typing "qa!<Enter>". You don't
  247. get a prompt thus you can't see Vim is waiting for you to type
  248. something.
  249. Initializations are skipped (except the ones given with the
  250. "-u" argument).
  251. Example: >
  252. vim -e -s < thefilter thefile
  253. < For the opposite, to see errors from the script, execute the
  254. file with the |-u| flag: >
  255. vim -u thefilter thefile
  256. <
  257. *-b*
  258. -b Binary mode. File I/O will only recognize <NL> to separate
  259. lines. The 'expandtab' option will be reset. The 'textwidth'
  260. option is set to 0. 'modeline' is reset. The 'binary' option
  261. is set. This is done after reading the vimrc/exrc files but
  262. before reading any file in the arglist. See also
  263. |edit-binary|.
  264. *-l*
  265. -l Lisp mode. Sets the 'lisp' and 'showmatch' options on.
  266. *-A*
  267. -A Arabic mode. Sets the 'arabic' option on. {only when
  268. compiled with the |+arabic| features (which include
  269. |+rightleft|), otherwise Vim gives an error message
  270. and exits}
  271. *-F*
  272. -F This was used for Farsi mode, which has been removed.
  273. See |farsi.txt|.
  274. *-H*
  275. -H Hebrew mode. Sets the 'hkmap' and 'rightleft' options on.
  276. {only when compiled with the |+rightleft| feature, otherwise
  277. Vim gives an error message and exits}
  278. *-V* *verbose*
  279. -V[N] Verbose. Sets the 'verbose' option to [N] (default: 10).
  280. Messages will be given for each file that is ":source"d and
  281. for reading or writing a viminfo file. Can be used to find
  282. out what is happening upon startup and exit.
  283. Example: >
  284. vim -V8 foobar
  285. -V[N]{filename}
  286. Like -V and set 'verbosefile' to {filename}. The result is
  287. that messages are not displayed but written to the file
  288. {filename}. {filename} must not start with a digit.
  289. Example: >
  290. vim -V20vimlog foobar
  291. <
  292. --log {filename} *--log*
  293. Start logging and write entries to {filename}.
  294. This works like calling `ch_logfile({filename}, 'ao')` very
  295. early during startup.
  296. {only available with the |+eval| feature}
  297. *-D*
  298. -D Debugging. Go to debugging mode when executing the first
  299. command from a script. |debug-mode|
  300. {not available when compiled without the |+eval| feature}
  301. *-C*
  302. -C Compatible mode. Sets the 'compatible' option. You can use
  303. this to get 'compatible', even though a .vimrc file exists.
  304. Keep in mind that the command ":set nocompatible" in some
  305. plugin or startup script overrules this, so you may end up
  306. with 'nocompatible' anyway. To find out, use: >
  307. :verbose set compatible?
  308. < Several plugins won't work with 'compatible' set. You may
  309. want to set it after startup this way: >
  310. vim "+set cp" filename
  311. < Also see |compatible-default|.
  312. *-N*
  313. -N Not compatible mode. Resets the 'compatible' option. You can
  314. use this to get 'nocompatible', when there is no .vimrc file
  315. or when using "-u NONE".
  316. Also see |compatible-default|.
  317. *-y* *easy*
  318. -y Easy mode. Implied for |evim| and |eview|. Starts with
  319. 'insertmode' set and behaves like a click-and-type editor.
  320. This sources the script $VIMRUNTIME/evim.vim. Mappings are
  321. set up to work like most click-and-type editors, see
  322. |evim-keys|. The GUI is started when available.
  323. *-n*
  324. -n No swap file will be used. Recovery after a crash will be
  325. impossible. Handy if you want to view or edit a file on a
  326. very slow medium (e.g., a floppy).
  327. Can also be done with ":set updatecount=0". You can switch it
  328. on again by setting the 'updatecount' option to some value,
  329. e.g., ":set uc=100".
  330. NOTE: Don't combine -n with -b, making -nb, because that has a
  331. different meaning: |-nb|.
  332. 'updatecount' is set to 0 AFTER executing commands from a
  333. vimrc file, but before the GUI initializations. Thus it
  334. overrides a setting for 'updatecount' in a vimrc file, but not
  335. in a gvimrc file. See |startup|.
  336. When you want to reduce accesses to the disk (e.g., for a
  337. laptop), don't use "-n", but set 'updatetime' and
  338. 'updatecount' to very big numbers, and type ":preserve" when
  339. you want to save your work. This way you keep the possibility
  340. for crash recovery.
  341. *-o*
  342. -o[N] Open N windows, split horizontally. If [N] is not given,
  343. one window is opened for every file given as argument. If
  344. there is not enough room, only the first few files get a
  345. window. If there are more windows than arguments, the last
  346. few windows will be editing an empty file.
  347. *-O*
  348. -O[N] Open N windows, split vertically. Otherwise it's like -o.
  349. If both the -o and the -O option are given, the last one on
  350. the command line determines how the windows will be split.
  351. *-p*
  352. -p[N] Open N tab pages. If [N] is not given, one tab page is opened
  353. for every file given as argument. The maximum is set with
  354. 'tabpagemax' pages (default 10). If there are more tab pages
  355. than arguments, the last few tab pages will be editing an
  356. empty file. Also see |tabpage|.
  357. *-T*
  358. -T {terminal} Set the terminal type to "terminal". This influences the
  359. codes that Vim will send to your terminal. This is normally
  360. not needed, because Vim will be able to find out what type
  361. of terminal you are using. (See |terminal-info|.)
  362. *--not-a-term*
  363. --not-a-term Tells Vim that the user knows that the input and/or output is
  364. not connected to a terminal. This will avoid the warning and
  365. the two second delay that would happen.
  366. Also avoids the "Reading from stdin..." message.
  367. Also avoids the "N files to edit" message.
  368. --gui-dialog-file {name} *--gui-dialog-file*
  369. When using the GUI, instead of showing a dialog, write the
  370. title and message of the dialog to file {name}. The file is
  371. created or appended to. Only useful for testing, to avoid
  372. that the test gets stuck on a dialog that can't be seen.
  373. Without the GUI the argument is ignored.
  374. *--ttyfail*
  375. --ttyfail When the stdin or stdout is not a terminal (tty) then exit
  376. right away.
  377. *-d*
  378. -d Start in diff mode, like |vimdiff|.
  379. {not available when compiled without the |+diff| feature}
  380. -d {device} Only on the Amiga and when not compiled with the |+diff|
  381. feature. Works like "-dev".
  382. *-dev*
  383. -dev {device} Only on the Amiga: The {device} is opened to be used for
  384. editing.
  385. Normally you would use this to set the window position and
  386. size: "-d con:x/y/width/height", e.g.,
  387. "-d con:30/10/600/150". But you can also use it to start
  388. editing on another device, e.g., AUX:.
  389. *-f*
  390. -f GUI: Do not disconnect from the program that started Vim.
  391. 'f' stands for "foreground". If omitted, the GUI forks a new
  392. process and exits the current one. "-f" should be used when
  393. gvim is started by a program that will wait for the edit
  394. session to finish (e.g., mail or readnews). If you want gvim
  395. never to fork, include 'f' in 'guioptions' in your |gvimrc|.
  396. Careful: You can use "-gf" to start the GUI in the foreground,
  397. but "-fg" is used to specify the foreground color. |gui-fork|
  398. Amiga: Do not restart Vim to open a new window. This
  399. option should be used when Vim is started by a program that
  400. will wait for the edit session to finish (e.g., mail or
  401. readnews). See |amiga-window|.
  402. MS-Windows: This option is not supported. However, when
  403. running Vim with an installed vim.bat or gvim.bat file it
  404. works.
  405. *--nofork*
  406. --nofork GUI: Do not fork. Same as |-f|.
  407. *-u* *E282*
  408. -u {vimrc} The file {vimrc} is read for initializations. Most other
  409. initializations are skipped; see |initialization|.
  410. This can be used to start Vim in a special mode, with special
  411. mappings and settings. A shell alias can be used to make
  412. this easy to use. For example: >
  413. alias vimc vim -u ~/.c_vimrc !*
  414. < Also consider using autocommands; see |autocommand|.
  415. When {vimrc} is equal to "NONE" (all uppercase), all
  416. initializations from files and environment variables are
  417. skipped, including reading the |gvimrc| file when the GUI
  418. starts. Loading plugins is also skipped.
  419. When {vimrc} is equal to "NORC" (all uppercase), this has the
  420. same effect as "NONE", but loading plugins is not skipped.
  421. When {vimrc} is equal to "DEFAULTS" (all uppercase), this has
  422. the same effect as "NONE", but the |defaults.vim| script is
  423. loaded, which will also set 'nocompatible'. Also see
  424. |--clean|.
  425. Using the "-u" argument with another argument than DEFAULTS
  426. has the side effect that the 'compatible' option will be on by
  427. default. This can have unexpected effects. See
  428. |'compatible'|.
  429. *-U* *E230*
  430. -U {gvimrc} The file {gvimrc} is read for initializations when the GUI
  431. starts. Other GUI initializations are skipped. When {gvimrc}
  432. is equal to "NONE", no file is read for GUI initializations at
  433. all. |gui-init|
  434. Exception: Reading the system-wide menu file is always done.
  435. *-i*
  436. -i {viminfo} The file "viminfo" is used instead of the default viminfo
  437. file. If the name "NONE" is used (all uppercase), no viminfo
  438. file is read or written, even if 'viminfo' is set or when
  439. ":rv" or ":wv" are used. See also |viminfo-file|.
  440. *--clean*
  441. --clean Similar to "-u DEFAULTS -U NONE -i NONE":
  442. - initializations from files and environment variables is
  443. skipped
  444. - 'runtimepath' and 'packpath' are set to exclude home
  445. directory entries (does not happen with -u DEFAULTS).
  446. - the |defaults.vim| script is loaded, which implies
  447. 'nocompatible': use Vim defaults
  448. - no |gvimrc| script is loaded
  449. - no viminfo file is read or written
  450. Note that a following "-u" argument overrules the effect of
  451. "-u DEFAULTS".
  452. *-x*
  453. -x Use encryption to read/write files. Will prompt for a key,
  454. which is then stored in the 'key' option. All writes will
  455. then use this key to encrypt the text. The '-x' argument is
  456. not needed when reading a file, because there is a check if
  457. the file that is being read has been encrypted, and Vim asks
  458. for a key automatically. |encryption|
  459. *-X*
  460. -X Do not try connecting to the X server to get the current
  461. window title and copy/paste using the X clipboard. This
  462. avoids a long startup time when running Vim in a terminal
  463. emulator and the connection to the X server is slow.
  464. See |--startuptime| to find out if affects you.
  465. Only makes a difference on Unix or VMS, when compiled with the
  466. |+X11| feature. Otherwise it's ignored.
  467. To disable the connection only for specific terminals, see the
  468. 'clipboard' option.
  469. When the X11 Session Management Protocol (XSMP) handler has
  470. been built in, the -X option also disables that connection as
  471. it, too, may have undesirable delays.
  472. When the connection is desired later anyway (e.g., for
  473. client-server messages), call the |serverlist()| function.
  474. This does not enable the XSMP handler though.
  475. *-s*
  476. -s {scriptin} The script file "scriptin" is read. The characters in the
  477. file are interpreted as if you had typed them. The same can
  478. be done with the command ":source! {scriptin}". If the end
  479. of the file is reached before the editor exits, further
  480. characters are read from the keyboard. Only works when not
  481. started in Ex mode, see |-s-ex|. See also |complex-repeat|.
  482. *-w_nr*
  483. -w {number}
  484. -w{number} Set the 'window' option to {number}.
  485. *-w*
  486. -w {scriptout} All the characters that you type are recorded in the file
  487. "scriptout", until you exit Vim. This is useful if you want
  488. to create a script file to be used with "vim -s" or
  489. ":source!". When the "scriptout" file already exists, new
  490. characters are appended. See also |complex-repeat|.
  491. {scriptout} cannot start with a digit.
  492. If you want to record what is typed in a human readable for
  493. you can use |ch_logfile()|, It adds "raw key input" lines.
  494. Also see |--log|.
  495. *-W*
  496. -W {scriptout} Like -w, but do not append, overwrite an existing file.
  497. --remote [+{cmd}] {file} ...
  498. Open the {file} in another Vim that functions as a server.
  499. Any non-file arguments must come before this.
  500. See |--remote|.
  501. --remote-silent [+{cmd}] {file} ...
  502. Like --remote, but don't complain if there is no server.
  503. See |--remote-silent|.
  504. --remote-wait [+{cmd}] {file} ...
  505. Like --remote, but wait for the server to finish editing the
  506. file(s).
  507. See |--remote-wait|.
  508. --remote-wait-silent [+{cmd}] {file} ...
  509. Like --remote-wait, but don't complain if there is no server.
  510. See |--remote-wait-silent|.
  511. --servername {name}
  512. Specify the name of the Vim server to send to or to become.
  513. See |--servername|.
  514. --remote-send {keys}
  515. Send {keys} to a Vim server and exit.
  516. See |--remote-send|.
  517. --remote-expr {expr}
  518. Evaluate {expr} in another Vim that functions as a server.
  519. The result is printed on stdout.
  520. See |--remote-expr|.
  521. --serverlist Output a list of Vim server names and exit. See
  522. |--serverlist|.
  523. --socketid {id} *--socketid*
  524. GTK+ GUI Vim only. Make gvim try to use GtkPlug mechanism, so
  525. that it runs inside another window. See |gui-gtk-socketid|
  526. for details.
  527. --windowid {id} *--windowid*
  528. Win32 GUI Vim only. Make gvim try to use the window {id} as a
  529. parent, so that it runs inside that window. See
  530. |gui-w32-windowid| for details.
  531. --echo-wid *--echo-wid*
  532. GTK+ GUI Vim only. Make gvim echo the Window ID on stdout,
  533. which can be used to run gvim in a kpart widget. The format
  534. of the output is: >
  535. WID: 12345\n
  536. --role {role} *--role*
  537. GTK+ 2 GUI only. Set the role of the main window to {role}.
  538. The window role can be used by a window manager to uniquely
  539. identify a window, in order to restore window placement and
  540. such. The --role argument is passed automatically when
  541. restoring the session on login. See |gui-gnome-session|
  542. -P {parent-title} *-P* *MDI* *E671* *E672*
  543. Win32 only: Specify the title of the parent application. When
  544. possible, Vim will run in an MDI window inside the
  545. application.
  546. {parent-title} must appear in the window title of the parent
  547. application. Make sure that it is specific enough.
  548. Note that the implementation is still primitive. It won't
  549. work with all applications and the menu doesn't work.
  550. -nb *-nb*
  551. -nb={fname}
  552. -nb:{hostname}:{addr}:{password}
  553. Attempt connecting to Netbeans and become an editor server for
  554. it. The second form specifies a file to read connection info
  555. from. The third form specifies the hostname, address and
  556. password for connecting to Netbeans. |netbeans-run|
  557. {only available when compiled with the |+netbeans_intg|
  558. feature; if not then -nb will make Vim exit}
  559. If the executable is called "view", Vim will start in Readonly mode. This is
  560. useful if you can make a hard or symbolic link from "view" to "vim".
  561. Starting in Readonly mode can also be done with "vim -R".
  562. If the executable is called "ex", Vim will start in "Ex" mode. This means it
  563. will accept only ":" commands. But when the "-v" argument is given, Vim will
  564. start in Normal mode anyway.
  565. Additional arguments are available on unix like systems when compiled with
  566. X11 GUI support. See |gui-resources|.
  567. ==============================================================================
  568. 2. Vim on the Amiga *starting-amiga*
  569. Starting Vim from the Workbench *workbench*
  570. -------------------------------
  571. Vim can be started from the Workbench by clicking on its icon twice. It will
  572. then start with an empty buffer.
  573. Vim can be started to edit one or more files by using a "Project" icon. The
  574. "Default Tool" of the icon must be the full pathname of the Vim executable.
  575. The name of the ".info" file must be the same as the name of the text file.
  576. By clicking on this icon twice, Vim will be started with the file name as
  577. current file name, which will be read into the buffer (if it exists). You can
  578. edit multiple files by pressing the shift key while clicking on icons, and
  579. clicking twice on the last one. The "Default Tool" for all these icons must
  580. be the same.
  581. It is not possible to give arguments to Vim, other than file names, from the
  582. workbench.
  583. Vim window *amiga-window*
  584. ----------
  585. Vim will run in the CLI window where it was started. If Vim was started with
  586. the "run" or "runback" command, or if Vim was started from the workbench, it
  587. will open a window of its own.
  588. Technical detail:
  589. To open the new window a little trick is used. As soon as Vim
  590. recognizes that it does not run in a normal CLI window, it will
  591. create a script file in "t:". This script file contains the same
  592. command as the one Vim was started with, and an "endcli" command.
  593. This script file is then executed with a "newcli" command (the "c:run"
  594. and "c:newcli" commands are required for this to work). The script
  595. file will hang around until reboot, or until you delete it. This
  596. method is required to get the ":sh" and ":!" commands to work
  597. correctly. But when Vim was started with the -f option (foreground
  598. mode), this method is not used. The reason for this is that
  599. when a program starts Vim with the -f option it will wait for Vim to
  600. exit. With the script trick, the calling program does not know when
  601. Vim exits. The -f option can be used when Vim is started by a mail
  602. program which also waits for the edit session to finish. As a
  603. consequence, the ":sh" and ":!" commands are not available when the
  604. -f option is used.
  605. Vim will automatically recognize the window size and react to window
  606. resizing. Under Amiga DOS 1.3, it is advised to use the fastfonts program,
  607. "FF", to speed up display redrawing.
  608. ==============================================================================
  609. 3. Running eVim *evim-keys*
  610. EVim runs Vim as click-and-type editor. This is very unlike the original Vi
  611. idea. But it helps for people that don't use Vim often enough to learn the
  612. commands. Hopefully they will find out that learning to use Normal mode
  613. commands will make their editing much more effective.
  614. In Evim these options are changed from their default value:
  615. :set nocompatible Use Vim improvements
  616. :set insertmode Remain in Insert mode most of the time
  617. :set hidden Keep invisible buffers loaded
  618. :set backup Keep backup files (not for VMS)
  619. :set backspace=2 Backspace over everything
  620. :set autoindent auto-indent new lines
  621. :set history=50 keep 50 lines of Ex commands
  622. :set ruler show the cursor position
  623. :set incsearch show matches halfway typing a pattern
  624. :set mouse=a use the mouse in all modes
  625. :set hlsearch highlight all matches for a search pattern
  626. :set whichwrap+=<,>,[,] <Left> and <Right> wrap around line breaks
  627. :set guioptions-=a non-Unix only: don't do auto-select
  628. Key mappings:
  629. <CTRL-Q> quit, using `:confirm` prompt if there are changes
  630. <Down> moves by screen lines rather than file lines
  631. <Up> idem
  632. Q does "gq", formatting, instead of Ex mode
  633. <BS> in Visual mode: deletes the selection
  634. CTRL-X in Visual mode: Cut to clipboard
  635. <S-Del> idem
  636. CTRL-C in Visual mode: Copy to clipboard
  637. <C-Insert> idem
  638. CTRL-V Pastes from the clipboard (in any mode)
  639. <S-Insert> idem
  640. CTRL-Z undo
  641. CTRL-Y redo
  642. <M-Space> system menu
  643. CTRL-A select all
  644. <C-Tab> next window, CTRL-W w
  645. <C-F4> close window, CTRL-W c
  646. Additionally:
  647. - ":behave mswin" is used |:behave|
  648. - syntax highlighting is enabled
  649. - filetype detection is enabled, filetype plugins and indenting is enabled
  650. - in a text file 'textwidth' is set to 78
  651. One hint: If you want to go to Normal mode to be able to type a sequence of
  652. commands, use CTRL-L. |i_CTRL-L|
  653. There is no way to stop "easy mode", you need to exit Vim.
  654. ==============================================================================
  655. 4. Initialization *initialization* *startup*
  656. This section is about the non-GUI version of Vim. See |gui-fork| for
  657. additional initialization when starting the GUI.
  658. At startup, Vim checks environment variables and files and sets values
  659. accordingly. Vim proceeds in this order:
  660. 1. Set the 'shell' and 'term' option *SHELL* *COMSPEC* *TERM*
  661. The environment variable SHELL, if it exists, is used to set the
  662. 'shell' option. On Win32, the COMSPEC variable is used
  663. if SHELL is not set.
  664. The environment variable TERM, if it exists, is used to set the 'term'
  665. option. However, 'term' will change later when starting the GUI (step
  666. 8 below).
  667. 2. Process the arguments
  668. The options and file names from the command that start Vim are
  669. inspected. Buffers are created for all files (but not loaded yet).
  670. The |-V| argument can be used to display or log what happens next,
  671. useful for debugging the initializations.
  672. 3. Execute Ex commands, from environment variables and/or files
  673. An environment variable is read as one Ex command line, where multiple
  674. commands must be separated with '|' or "<NL>".
  675. *vimrc* *exrc*
  676. A file that contains initialization commands is called a "vimrc" file.
  677. Each line in a vimrc file is executed as an Ex command line. It is
  678. sometimes also referred to as "exrc" file. They are the same type of
  679. file, but "exrc" is what Vi always used, "vimrc" is a Vim specific
  680. name. Also see |vimrc-intro|.
  681. Places for your personal initializations:
  682. Unix $HOME/.vimrc or $HOME/.vim/vimrc
  683. MS-Windows $HOME/_vimrc, $HOME/vimfiles/vimrc
  684. or $VIM/_vimrc
  685. Amiga s:.vimrc, home:.vimrc, home:vimfiles:vimrc
  686. or $VIM/.vimrc
  687. Haiku $HOME/config/settings/vim/vimrc
  688. The files are searched in the order specified above and only the first
  689. one that is found is read.
  690. RECOMMENDATION: Put all your Vim configuration stuff in the
  691. $HOME/.vim/ directory ($HOME/vimfiles/ for MS-Windows). That makes it
  692. easy to copy it to another system.
  693. If Vim was started with "-u filename", the file "filename" is used.
  694. All following initializations until 4. are skipped. $MYVIMRC is not
  695. set.
  696. "vim -u NORC" can be used to skip these initializations without
  697. reading a file. "vim -u NONE" also skips loading plugins. |-u|
  698. If Vim was started in Ex mode with the "-s" argument, all following
  699. initializations until 4. are skipped. Only the "-u" option is
  700. interpreted.
  701. *evim.vim*
  702. a. If vim was started as |evim| or |eview| or with the |-y| argument, the
  703. script $VIMRUNTIME/evim.vim will be loaded.
  704. *system-vimrc*
  705. b. For Unix, MS-Windows, VMS, Macintosh and Amiga the system vimrc file
  706. is read for initializations. The path of this file is shown with the
  707. ":version" command. Mostly it's "$VIM/vimrc". Note that this file is
  708. ALWAYS read in 'compatible' mode, since the automatic resetting of
  709. 'compatible' is only done later. Add a ":set nocp" command if you
  710. like. For the Macintosh the $VIMRUNTIME/macmap.vim is read.
  711. *VIMINIT* *.vimrc* *_vimrc* *EXINIT* *.exrc* *_exrc* *$MYVIMRC*
  712. c. Five places are searched for initializations. The first that exists
  713. is used, the others are ignored. The $MYVIMRC environment variable is
  714. set to the file that was first found, unless $MYVIMRC was already set
  715. and when using VIMINIT.
  716. I The environment variable VIMINIT (see also |compatible-default|) (*)
  717. The value of $VIMINIT is used as an Ex command line.
  718. II The user vimrc file(s):
  719. "$HOME/.vimrc" (for Unix) (*)
  720. "$HOME/.vim/vimrc" (for Unix) (*)
  721. "s:.vimrc" (for Amiga) (*)
  722. "home:.vimrc" (for Amiga) (*)
  723. "home:vimfiles:vimrc" (for Amiga) (*)
  724. "$VIM/.vimrc" (for Amiga) (*)
  725. "$HOME/_vimrc" (for Win32) (*)
  726. "$HOME/vimfiles/vimrc" (for Win32) (*)
  727. "$VIM/_vimrc" (for Win32) (*)
  728. "$HOME/config/settings/vim/vimrc" (for Haiku) (*)
  729. Note: For Unix and Amiga, when ".vimrc" does not exist,
  730. "_vimrc" is also tried, in case an MS-DOS compatible file
  731. system is used. For MS-Windows ".vimrc" is checked after
  732. "_vimrc", in case long file names are used.
  733. Note: For Win32, "$HOME" is checked first. If no "_vimrc" or
  734. ".vimrc" is found there, "$VIM" is tried. See |$VIM| for when
  735. $VIM is not set.
  736. III The environment variable EXINIT.
  737. The value of $EXINIT is used as an Ex command line.
  738. IV The user exrc file(s). Same as for the user vimrc file, but with
  739. "vimrc" replaced by "exrc". But only one of ".exrc" and "_exrc" is
  740. used, depending on the system. And without the (*)!
  741. V The default vimrc file, $VIMRUNTIME/defaults.vim. This sets up
  742. options values and has "syntax on" and "filetype on" commands,
  743. which is what most new users will want. See |defaults.vim|.
  744. d. If the 'exrc' option is on (which is NOT the default), the current
  745. directory is searched for three files. The first that exists is used,
  746. the others are ignored.
  747. - The file ".vimrc" (for Unix, Amiga) (*)
  748. "_vimrc" (for Win32) (*)
  749. - The file "_vimrc" (for Unix, Amiga) (*)
  750. ".vimrc" (for Win32) (*)
  751. - The file ".exrc" (for Unix, Amiga)
  752. "_exrc" (for Win32)
  753. (*) Using this file or environment variable will cause 'compatible' to be
  754. off by default. See |compatible-default|.
  755. Note: When using the |mzscheme| interface, it is initialized after loading
  756. the vimrc file. Changing 'mzschemedll' later has no effect.
  757. 4. Load the plugin scripts. *load-plugins*
  758. This does the same as the command: >
  759. :runtime! plugin/**/*.vim
  760. < The result is that all directories in the 'runtimepath' option will be
  761. searched for the "plugin" sub-directory and all files ending in ".vim"
  762. will be sourced (in alphabetical order per directory), also in
  763. subdirectories.
  764. However, directories in 'runtimepath' ending in "after" are skipped
  765. here and only loaded after packages, see below.
  766. Loading plugins won't be done when:
  767. - The 'loadplugins' option was reset in a vimrc file.
  768. - The |--noplugin| command line argument is used.
  769. - The |--clean| command line argument is used.
  770. - The "-u NONE" command line argument is used |-u|.
  771. - When Vim was compiled without the |+eval| feature.
  772. Note that using "-c 'set noloadplugins'" doesn't work, because the
  773. commands from the command line have not been executed yet. You can
  774. use "--cmd 'set noloadplugins'" or "--cmd 'set loadplugins'" |--cmd|.
  775. Packages are loaded. These are plugins, as above, but found in the
  776. "start" directory of each entry in 'packpath'. Every plugin directory
  777. found is added in 'runtimepath' and then the plugins are sourced. See
  778. |packages|.
  779. The plugins scripts are loaded, as above, but now only the directories
  780. ending in "after" are used. Note that 'runtimepath' will have changed
  781. if packages have been found, but that should not add a directory
  782. ending in "after".
  783. 5. Set 'shellpipe' and 'shellredir'
  784. The 'shellpipe' and 'shellredir' options are set according to the
  785. value of the 'shell' option, unless they have been set before.
  786. This means that Vim will figure out the values of 'shellpipe' and
  787. 'shellredir' for you, unless you have set them yourself.
  788. 6. Set 'updatecount' to zero, if "-n" command argument used
  789. 7. Set binary options
  790. If the "-b" flag was given to Vim, the options for binary editing will
  791. be set now. See |-b|.
  792. 8. Perform GUI initializations
  793. Only when starting "gvim", the GUI initializations will be done. See
  794. |gui-init|.
  795. 9. Read the viminfo file
  796. If the 'viminfo' option is not empty, the viminfo file is read. See
  797. |viminfo-file|.
  798. 10. Read the quickfix file
  799. If the "-q" flag was given to Vim, the quickfix file is read. If this
  800. fails, Vim exits.
  801. 11. Open all windows
  802. When the |-o| flag was given, windows will be opened (but not
  803. displayed yet).
  804. When the |-p| flag was given, tab pages will be created (but not
  805. displayed yet).
  806. When switching screens, it happens now. Redrawing starts.
  807. If the "-q" flag was given to Vim, the first error is jumped to.
  808. Buffers for all windows will be loaded, without triggering |BufAdd|
  809. autocommands.
  810. 12. Execute startup commands
  811. If a "-t" flag was given to Vim, the tag is jumped to.
  812. The commands given with the |-c| and |+cmd| arguments are executed.
  813. If the 'insertmode' option is set, Insert mode is entered.
  814. The starting flag is reset, has("vim_starting") will now return zero.
  815. The |v:vim_did_enter| variable is set to 1.
  816. The |VimEnter| autocommands are executed.
  817. The $MYVIMRC or $MYGVIMRC file will be set to the first found vimrc and/or
  818. gvimrc file.
  819. Some hints on using initializations ~
  820. Standard setup:
  821. Create a vimrc file to set the default settings and mappings for all your edit
  822. sessions. Put it in a place so that it will be found by 3b:
  823. ~/.vimrc (Unix)
  824. s:.vimrc (Amiga)
  825. $VIM\_vimrc (Win32)
  826. ~/config/settings/vim/vimrc (Haiku)
  827. Note that creating a vimrc file will cause the 'compatible' option to be off
  828. by default. See |compatible-default|.
  829. Local setup:
  830. Put all commands that you need for editing a specific directory only into a
  831. vimrc file and place it in that directory under the name ".vimrc" ("_vimrc"
  832. for Win32). NOTE: To make Vim look for these special files you have to turn
  833. on the option 'exrc'. See |trojan-horse| too.
  834. System setup:
  835. This only applies if you are managing a Unix system with several users and
  836. want to set the defaults for all users. Create a vimrc file with commands
  837. for default settings and mappings and put it in the place that is given with
  838. the ":version" command.
  839. Saving the current state of Vim to a file ~
  840. Whenever you have changed values of options or when you have created a
  841. mapping, then you may want to save them in a vimrc file for later use. See
  842. |save-settings| about saving the current state of settings to a file.
  843. Avoiding setup problems for Vi users ~
  844. Vi uses the variable EXINIT and the file "~/.exrc". So if you do not want to
  845. interfere with Vi, then use the variable VIMINIT and the file "vimrc" instead.
  846. Amiga environment variables ~
  847. On the Amiga, two types of environment variables exist. The ones set with the
  848. DOS 1.3 (or later) setenv command are recognized. See the AmigaDos 1.3
  849. manual. The environment variables set with the old Manx Set command (before
  850. version 5.0) are not recognized.
  851. MS-Windows line separators ~
  852. On MS-Windows, Vim assumes that all the vimrc files have <CR><NL> pairs as
  853. line separators. This will give problems if you have a file with only <NL>s
  854. and have a line like ":map xx yy^M". The trailing ^M will be ignored.
  855. Vi compatible default value ~
  856. *compatible-default*
  857. When Vim starts, the 'compatible' option is on. This will be used when Vim
  858. starts its initializations. But as soon as:
  859. - a user vimrc file is found, or
  860. - a vimrc file in the current directory is found, or
  861. - the "VIMINIT" environment variable is set, or
  862. - the "-N" command line argument is given, or
  863. - the "--clean" command line argument is given, or
  864. - the |defaults.vim| script is loaded, or
  865. - a gvimrc file was found,
  866. then the option will be set to 'nocompatible'.
  867. Note that this does NOT happen when a system-wide vimrc file was found.
  868. This has the side effect of setting or resetting other options (see
  869. 'compatible'). But only the options that have not been set or reset will be
  870. changed. This has the same effect like the value of 'compatible' had this
  871. value when starting Vim.
  872. 'compatible' is NOT reset, and |defaults.vim| is not loaded:
  873. - when Vim was started with the |-u| command line argument, especially with
  874. "-u NONE", or
  875. - when started with the |-C| command line argument, or
  876. - when the name of the executable ends in "ex". (This has been done to make
  877. Vim behave like "ex", when it is started as "ex")
  878. But there is a side effect of setting or resetting 'compatible' at the moment
  879. a .vimrc file is found: Mappings are interpreted the moment they are
  880. encountered. This makes a difference when using things like "<CR>". If the
  881. mappings depend on a certain value of 'compatible', set or reset it before
  882. giving the mapping.
  883. Defaults without a .vimrc file ~
  884. *defaults.vim* *E1187*
  885. If Vim is started normally and no user vimrc file is found, the
  886. $VIMRUNTIME/defaults.vim script is loaded. This will set 'compatible' off,
  887. switch on syntax highlighting and a few more things. See the script for
  888. details. NOTE: this is done since Vim 8.0, not in Vim 7.4. (it was added in
  889. patch 7.4.2111 to be exact).
  890. This should work well for new Vim users. If you create your own .vimrc, it is
  891. recommended to add these lines somewhere near the top: >
  892. unlet! skip_defaults_vim
  893. source $VIMRUNTIME/defaults.vim
  894. Then Vim works like before you had a .vimrc. Copying $VIMRUNTIME/vimrc_example
  895. is way to do this. Alternatively, you can copy defaults.vim to your .vimrc
  896. and modify it (but then you won't get updates when it changes).
  897. If you don't like some of the defaults, you can still source defaults.vim and
  898. revert individual settings. See the defaults.vim file for hints on how to
  899. revert each item.
  900. *skip_defaults_vim*
  901. If you use a system-wide vimrc and don't want defaults.vim to change settings,
  902. set the "skip_defaults_vim" variable. If this was set and you want to load
  903. defaults.vim from your .vimrc, first unlet skip_defaults_vim, as in the
  904. example above.
  905. Avoiding trojan horses ~
  906. *trojan-horse*
  907. While reading the "vimrc" or the "exrc" file in the current directory, some
  908. commands can be disabled for security reasons by setting the 'secure' option.
  909. This is always done when executing the command from a tags file. Otherwise it
  910. would be possible that you accidentally use a vimrc or tags file that somebody
  911. else created and contains nasty commands. The disabled commands are the ones
  912. that start a shell, the ones that write to a file, and ":autocmd". The ":map"
  913. commands are echoed, so you can see which keys are being mapped.
  914. If you want Vim to execute all commands in a local vimrc file, you
  915. can reset the 'secure' option in the EXINIT or VIMINIT environment variable or
  916. in the global "exrc" or "vimrc" file. This is not possible in "vimrc" or
  917. "exrc" in the current directory, for obvious reasons.
  918. On Unix systems, this only happens if you are not the owner of the
  919. vimrc file. Warning: If you unpack an archive that contains a vimrc or exrc
  920. file, it will be owned by you. You won't have the security protection. Check
  921. the vimrc file before you start Vim in that directory, or reset the 'exrc'
  922. option. Some Unix systems allow a user to do "chown" on a file. This makes
  923. it possible for another user to create a nasty vimrc and make you the owner.
  924. Be careful!
  925. When using tag search commands, executing the search command (the last
  926. part of the line in the tags file) is always done in secure mode. This works
  927. just like executing a command from a vimrc/exrc in the current directory.
  928. If Vim startup is slow ~
  929. *slow-start*
  930. If Vim takes a long time to start up, use the |--startuptime| argument to find
  931. out what happens. There are a few common causes:
  932. - If the Unix version was compiled with the GUI and/or X11 (check the output
  933. of ":version" for "+GUI" and "+X11"), it may need to load shared libraries
  934. and connect to the X11 server. Try compiling a version with GUI and X11
  935. disabled. This also should make the executable smaller.
  936. Use the |-X| command line argument to avoid connecting to the X server when
  937. running in a terminal.
  938. - If you have "viminfo" enabled, the loading of the viminfo file may take a
  939. while. You can find out if this is the problem by disabling viminfo for a
  940. moment (use the Vim argument "-i NONE", |-i|). Try reducing the number of
  941. lines stored in a register with ":set viminfo='20,<50,s10". |viminfo-file|.
  942. Intro message ~
  943. *:intro*
  944. When Vim starts without a file name, an introductory message is displayed (for
  945. those who don't know what Vim is). It is removed as soon as the display is
  946. redrawn in any way. To see the message again, use the ":intro" command (if
  947. there is not enough room, you will see only part of it).
  948. To avoid the intro message on startup, add the 'I' flag to 'shortmess'.
  949. *info-message*
  950. The |--help| and |--version| arguments cause Vim to print a message and then
  951. exit. Normally the message is sent to stdout, thus can be redirected to a
  952. file with: >
  953. vim --help >file
  954. From inside Vim: >
  955. :read !vim --help
  956. When using gvim, it detects that it might have been started from the desktop,
  957. without a terminal to show messages on. This is detected when both stdout and
  958. stderr are not a tty. This breaks the ":read" command, as used in the example
  959. above. To make it work again, set 'shellredir' to ">" instead of the default
  960. ">&": >
  961. :set shellredir=>
  962. :read !gvim --help
  963. This still won't work for systems where gvim does not use stdout at all
  964. though.
  965. ==============================================================================
  966. 5. $VIM and $VIMRUNTIME
  967. *$VIM*
  968. The environment variable "$VIM" is used to locate various user files for Vim,
  969. such as the user startup script ".vimrc". This depends on the system, see
  970. |startup|.
  971. To avoid the need for every user to set the $VIM environment variable, Vim
  972. will try to get the value for $VIM in this order:
  973. 1. The value defined by the $VIM environment variable. You can use this to
  974. make Vim look in a specific directory for its support files. Example: >
  975. setenv VIM /home/paul/vim
  976. 2. The path from 'helpfile' is used, unless it contains some environment
  977. variable too (the default is "$VIMRUNTIME/doc/help.txt": chicken-egg
  978. problem). The file name ("help.txt" or any other) is removed. Then
  979. trailing directory names are removed, in this order: "doc", "runtime" and
  980. "vim{version}" (e.g., "vim82").
  981. 3. For Win32 Vim tries to use the directory name of the executable. If it
  982. ends in "/src", this is removed. This is useful if you unpacked the .zip
  983. file in some directory, and adjusted the search path to find the vim
  984. executable. Trailing directory names are removed, in this order: "runtime"
  985. and "vim{version}" (e.g., "vim82").
  986. 4. For Unix the compile-time defined installation directory is used (see the
  987. output of ":version").
  988. Once Vim has done this once, it will set the $VIM environment variable. To
  989. change it later, use a ":let" command like this: >
  990. :let $VIM = "/home/paul/vim/"
  991. <
  992. *$VIMRUNTIME*
  993. The environment variable "$VIMRUNTIME" is used to locate various support
  994. files, such as the on-line documentation and files used for syntax
  995. highlighting. For example, the main help file is normally
  996. "$VIMRUNTIME/doc/help.txt".
  997. You don't normally set $VIMRUNTIME yourself, but let Vim figure it out. This
  998. is the order used to find the value of $VIMRUNTIME:
  999. 1. If the environment variable $VIMRUNTIME is set, it is used. You can use
  1000. this when the runtime files are in an unusual location.
  1001. 2. If "$VIM/vim{version}" exists, it is used. {version} is the version
  1002. number of Vim, without any '-' or '.'. For example: "$VIM/vim82". This is
  1003. the normal value for $VIMRUNTIME.
  1004. 3. If "$VIM/runtime" exists, it is used.
  1005. 4. The value of $VIM is used. This is for backwards compatibility with older
  1006. versions.
  1007. 5. When the 'helpfile' option is set and doesn't contain a '$', its value is
  1008. used, with "doc/help.txt" removed from the end.
  1009. For Unix, when there is a compiled-in default for $VIMRUNTIME (check the
  1010. output of ":version"), steps 2, 3 and 4 are skipped, and the compiled-in
  1011. default is used after step 5. This means that the compiled-in default
  1012. overrules the value of $VIM. This is useful if $VIM is "/etc" and the runtime
  1013. files are in "/usr/share/vim/vim82".
  1014. Once Vim has done this once, it will set the $VIMRUNTIME environment variable.
  1015. To change it later, use a ":let" command like this: >
  1016. :let $VIMRUNTIME = "/home/piet/vim/vim82"
  1017. In case you need the value of $VIMRUNTIME in a shell (e.g., for a script that
  1018. greps in the help files) you might be able to use this: >
  1019. VIMRUNTIME=`vim -e -T dumb --cmd 'exe "set t_cm=\<C-M>"|echo $VIMRUNTIME|quit' | tr -d '\015' `
  1020. Don't set $VIMRUNTIME to an empty value, some things may stop working.
  1021. ==============================================================================
  1022. 6. Suspending *suspend*
  1023. *iconize* *iconise* *CTRL-Z* *v_CTRL-Z*
  1024. CTRL-Z Suspend Vim, like ":stop".
  1025. Works in Normal and in Visual mode. In Insert and
  1026. Command-line mode, the CTRL-Z is inserted as a normal
  1027. character. In Visual mode Vim goes back to Normal
  1028. mode.
  1029. Note: if CTRL-Z undoes a change see |mswin.vim|.
  1030. :sus[pend][!] or *:sus* *:suspend* *:st* *:stop*
  1031. :st[op][!] Suspend Vim.
  1032. If the '!' is not given and 'autowrite' is set, every
  1033. buffer with changes and a file name is written out.
  1034. If the '!' is given or 'autowrite' is not set, changed
  1035. buffers are not written, don't forget to bring Vim
  1036. back to the foreground later!
  1037. In the GUI, suspending is implemented as iconising gvim. In MS-Windows, gvim
  1038. is minimized.
  1039. On many Unix systems, it is possible to suspend Vim with CTRL-Z. This is only
  1040. possible in Normal and Visual mode (see next chapter, |vim-modes|). Vim will
  1041. continue if you make it the foreground job again. On other systems, CTRL-Z
  1042. will start a new shell. This is the same as the ":sh" command. Vim will
  1043. continue if you exit from the shell.
  1044. In X-windows the selection is disowned when Vim suspends. this means you
  1045. can't paste it in another application (since Vim is going to sleep an attempt
  1046. to get the selection would make the program hang).
  1047. ==============================================================================
  1048. 7. Exiting *exiting*
  1049. There are several ways to exit Vim:
  1050. - Close the last window with `:quit`. Only when there are no changes.
  1051. - Close the last window with `:quit!`. Also when there are changes.
  1052. - Close all windows with `:qall`. Only when there are no changes.
  1053. - Close all windows with `:qall!`. Also when there are changes.
  1054. - Use `:cquit`. Also when there are changes.
  1055. When using `:cquit` or when there was an error message Vim exits with exit
  1056. code 1. Errors can be avoided by using `:silent!` or with `:catch`.
  1057. ==============================================================================
  1058. 8. Saving settings *save-settings*
  1059. Mostly you will edit your vimrc files manually. This gives you the greatest
  1060. flexibility. There are a few commands to generate a vimrc file automatically.
  1061. You can use these files as they are, or copy/paste lines to include in another
  1062. vimrc file.
  1063. *:mk* *:mkexrc*
  1064. :mk[exrc] [file] Write current key mappings and changed options to
  1065. [file] (default ".exrc" in the current directory),
  1066. unless it already exists.
  1067. :mk[exrc]! [file] Always write current key mappings and changed
  1068. options to [file] (default ".exrc" in the current
  1069. directory).
  1070. *:mkv* *:mkvi* *:mkvimrc*
  1071. :mkv[imrc][!] [file] Like ":mkexrc", but the default is ".vimrc" in the
  1072. current directory. The ":version" command is also
  1073. written to the file.
  1074. These commands will write ":map" and ":set" commands to a file, in such a way
  1075. that when these commands are executed, the current key mappings and options
  1076. will be set to the same values. The options 'columns', 'endofline',
  1077. 'fileformat', 'key', 'lines', 'modified', 'scroll', 'term', 'textmode',
  1078. 'ttyfast' and 'ttymouse' are not included, because these are terminal or file
  1079. dependent. Note that the options 'binary', 'paste' and 'readonly' are
  1080. included, this might not always be what you want.
  1081. When special keys are used in mappings, The 'cpoptions' option will be
  1082. temporarily set to its Vim default, to avoid the mappings to be
  1083. misinterpreted. This makes the file incompatible with Vi, but makes sure it
  1084. can be used with different terminals.
  1085. Only global mappings are stored, not mappings local to a buffer.
  1086. A common method is to use a default ".vimrc" file, make some modifications
  1087. with ":map" and ":set" commands and write the modified file. First read the
  1088. default ".vimrc" in with a command like ":source ~piet/.vimrc.Cprogs", change
  1089. the settings and then save them in the current directory with ":mkvimrc!". If
  1090. you want to make this file your default .vimrc, move it to your home directory
  1091. (on Unix), s: (Amiga) or $VIM directory (MS-Windows). You could also use
  1092. autocommands |autocommand| and/or modelines |modeline|.
  1093. *vimrc-option-example*
  1094. If you only want to add a single option setting to your vimrc, you can use
  1095. these steps:
  1096. 1. Edit your vimrc file with Vim.
  1097. 2. Play with the option until it's right. E.g., try out different values for
  1098. 'guifont'.
  1099. 3. Append a line to set the value of the option, using the expression register
  1100. '=' to enter the value. E.g., for the 'guifont' option: >
  1101. o:set guifont=<C-R>=&guifont<CR><Esc>
  1102. < [<C-R> is a CTRL-R, <CR> is a return, <Esc> is the escape key]
  1103. You need to escape special characters, esp. spaces.
  1104. Note that when you create a .vimrc file, this can influence the 'compatible'
  1105. option, which has several side effects. See |'compatible'|.
  1106. ":mkvimrc", ":mkexrc" and ":mksession" write the command to set or reset the
  1107. 'compatible' option to the output file first, because of these side effects.
  1108. ==============================================================================
  1109. 9. Views and Sessions *views-sessions*
  1110. This is introduced in sections |21.4| and |21.5| of the user manual.
  1111. *View* *view-file*
  1112. A View is a collection of settings that apply to one window. You can save a
  1113. View and when you restore it later, the text is displayed in the same way.
  1114. The options and mappings in this window will also be restored, so that you can
  1115. continue editing like when the View was saved.
  1116. *Session* *session-file*
  1117. A Session keeps the Views for all windows, plus the global settings. You can
  1118. save a Session and when you restore it later the window layout looks the same.
  1119. You can use a Session to quickly switch between different projects,
  1120. automatically loading the files you were last working on in that project.
  1121. Views and Sessions are a nice addition to viminfo-files, which are used to
  1122. remember information for all Views and Sessions together |viminfo-file|.
  1123. You can quickly start editing with a previously saved View or Session with the
  1124. |-S| argument: >
  1125. vim -S Session.vim
  1126. <
  1127. All this is {not available when compiled without the |+mksession| feature}.
  1128. *:mks* *:mksession*
  1129. :mks[ession][!] [file] Write a Vim script that restores the current editing
  1130. session.
  1131. When [!] is included an existing file is overwritten.
  1132. When [file] is omitted "Session.vim" is used.
  1133. The output of ":mksession" is like ":mkvimrc", but additional commands are
  1134. added to the file. Which ones depends on the 'sessionoptions' option. The
  1135. resulting file, when executed with a ":source" command:
  1136. 1. Restores global mappings and options, if 'sessionoptions' contains
  1137. "options". Script-local mappings will not be written.
  1138. 2. Restores global variables that start with an uppercase letter and contain
  1139. at least one lowercase letter, if 'sessionoptions' contains "globals".
  1140. 3. Closes all windows in the current tab page, except the current one; closes
  1141. all tab pages except the current one (this results in currently loaded
  1142. buffers to be unloaded, some may become hidden if 'hidden' is set or
  1143. otherwise specified); wipes out the current buffer, if it is empty
  1144. and unnamed.
  1145. 4. Restores the current directory if 'sessionoptions' contains "curdir", or
  1146. sets the current directory to where the Session file is if 'sessionoptions'
  1147. contains "sesdir".
  1148. 5. Restores GUI Vim window position, if 'sessionoptions' contains "winpos".
  1149. 6. Restores screen size, if 'sessionoptions' contains "resize".
  1150. 7. Reloads the buffer list, with the last cursor positions. If
  1151. 'sessionoptions' contains "buffers" then all buffers are restored,
  1152. including hidden and unloaded buffers. Otherwise only buffers in windows
  1153. are restored.
  1154. 8. Restores all windows with the same layout. If 'sessionoptions' contains
  1155. "help", help windows are restored. If 'sessionoptions' contains "blank",
  1156. windows editing a buffer without a name will be restored.
  1157. If 'sessionoptions' contains "winsize" and no (help/blank) windows were
  1158. left out, the window sizes are restored (relative to the screen size).
  1159. Otherwise, the windows are just given sensible sizes.
  1160. 9. Restores the Views for all the windows, as with |:mkview|. But
  1161. 'sessionoptions' is used instead of 'viewoptions'.
  1162. 10. If a file exists with the same name as the Session file, but ending in
  1163. "x.vim" (for eXtra), executes that as well. You can use *x.vim files to
  1164. specify additional settings and actions associated with a given Session,
  1165. such as creating menu items in the GUI version.
  1166. After restoring the Session, the full filename of your current Session is
  1167. available in the internal variable "v:this_session" |this_session-variable|.
  1168. An example mapping: >
  1169. :nmap <F2> :wa<Bar>exe "mksession! " .. v:this_session<CR>:so ~/sessions/
  1170. This saves the current Session, and starts off the command to load another.
  1171. A session includes all tab pages, unless "tabpages" was removed from
  1172. 'sessionoptions'. |tab-page|
  1173. The |SessionLoadPost| autocmd event is triggered after a session file is
  1174. loaded/sourced.
  1175. *SessionLoad-variable*
  1176. While the session file is loading the SessionLoad global variable is set to 1.
  1177. Plugins can use this to postpone some work until the SessionLoadPost event is
  1178. triggered.
  1179. *:mkvie* *:mkview*
  1180. :mkvie[w][!] [file] Write a Vim script that restores the contents of the
  1181. current window.
  1182. When [!] is included an existing file is overwritten.
  1183. When [file] is omitted or is a number from 1 to 9, a
  1184. name is generated and 'viewdir' prepended. When the
  1185. last path part of 'viewdir' does not exist, this
  1186. directory is created. E.g., when 'viewdir' is
  1187. "$VIM/vimfiles/view" then "view" is created in
  1188. "$VIM/vimfiles".
  1189. An existing file is always overwritten then. Use
  1190. |:loadview| to load this view again.
  1191. When [file] is the name of a file ('viewdir' is not
  1192. used), a command to edit the file is added to the
  1193. generated file.
  1194. The output of ":mkview" contains these items:
  1195. 1. The argument list used in the window. When the global argument list is
  1196. used it is reset to the global list.
  1197. The index in the argument list is also restored.
  1198. 2. The file being edited in the window. If there is no file, the window is
  1199. made empty.
  1200. 3. Restore mappings, abbreviations and options local to the window if
  1201. 'viewoptions' contains "options" or "localoptions". For the options it
  1202. restores only values that are local to the current buffer and values local
  1203. to the window.
  1204. When storing the view as part of a session and "options" is in
  1205. 'sessionoptions', global values for local options will be stored too.
  1206. 4. Restore folds when using manual folding and 'viewoptions' contains
  1207. "folds". Restore manually opened and closed folds.
  1208. 5. The scroll position and the cursor position in the file. Doesn't work very
  1209. well when there are closed folds.
  1210. 6. The local current directory, if it is different from the global current
  1211. directory and 'viewoptions' contains "curdir".
  1212. Note that Views and Sessions are not perfect:
  1213. - They don't restore everything. For example, defined functions, autocommands
  1214. and ":syntax on" are not included. Things like register contents and
  1215. command line history are in viminfo, not in Sessions or Views.
  1216. - Global option values are only set when they differ from the default value.
  1217. When the current value is not the default value, loading a Session will not
  1218. set it back to the default value. Local options will be set back to the
  1219. default value though.
  1220. - Existing mappings will be overwritten without warning. An existing mapping
  1221. may cause an error for ambiguity.
  1222. - When storing manual folds and when storing manually opened/closed folds,
  1223. changes in the file between saving and loading the view will mess it up.
  1224. - The Vim script is not very efficient. But still faster than typing the
  1225. commands yourself!
  1226. *:lo* *:loadview*
  1227. :lo[adview] [nr] Load the view for the current file. When [nr] is
  1228. omitted, the view stored with ":mkview" is loaded.
  1229. When [nr] is specified, the view stored with ":mkview
  1230. [nr]" is loaded.
  1231. The combination of ":mkview" and ":loadview" can be used to store up to ten
  1232. different views of a file. These are remembered in the directory specified
  1233. with the 'viewdir' option. The views are stored using the file name. If a
  1234. file is renamed or accessed through a (symbolic) link the view will not be
  1235. found.
  1236. You might want to clean up your 'viewdir' directory now and then.
  1237. To automatically save and restore views for *.c files: >
  1238. au BufWinLeave *.c mkview
  1239. au BufWinEnter *.c silent loadview
  1240. ==============================================================================
  1241. 10. The viminfo file *viminfo* *viminfo-file* *E136*
  1242. *E575* *E576* *E577*
  1243. If you exit Vim and later start it again, you would normally lose a lot of
  1244. information. The viminfo file can be used to remember that information, which
  1245. enables you to continue where you left off.
  1246. This is introduced in section |21.3| of the user manual.
  1247. The viminfo file is used to store:
  1248. - The command line history.
  1249. - The search string history.
  1250. - The input-line history.
  1251. - Contents of non-empty registers.
  1252. - Marks for several files.
  1253. - File marks, pointing to locations in files.
  1254. - Last search/substitute pattern (for 'n' and '&').
  1255. - The buffer list.
  1256. - Global variables.
  1257. The viminfo file is not supported when the |+viminfo| feature has been
  1258. disabled at compile time.
  1259. You could also use a Session file. The difference is that the viminfo file
  1260. does not depend on what you are working on. There normally is only one
  1261. viminfo file. Session files are used to save the state of a specific editing
  1262. Session. You could have several Session files, one for each project you are
  1263. working on. Viminfo and Session files together can be used to effectively
  1264. enter Vim and directly start working in your desired setup. |session-file|
  1265. *viminfo-read*
  1266. When Vim is started and the 'viminfo' option is non-empty, the contents of
  1267. the viminfo file are read and the info can be used in the appropriate places.
  1268. The |v:oldfiles| variable is filled. The marks are not read in at startup
  1269. (but file marks are). See |initialization| for how to set the 'viminfo'
  1270. option upon startup.
  1271. *viminfo-write*
  1272. When Vim exits and 'viminfo' is non-empty, the info is stored in the viminfo
  1273. file (it's actually merged with the existing one, if one exists). The
  1274. 'viminfo' option is a string containing information about what info should be
  1275. stored, and contains limits on how much should be stored (see 'viminfo').
  1276. Merging happens in two ways. Most items that have been changed or set in the
  1277. current Vim session are stored, and what was not changed is filled from what
  1278. is currently in the viminfo file. For example:
  1279. - Vim session A reads the viminfo, which contains variable START.
  1280. - Vim session B does the same
  1281. - Vim session A sets the variables AAA and BOTH and exits
  1282. - Vim session B sets the variables BBB and BOTH and exits
  1283. Now the viminfo will have:
  1284. START - it was in the viminfo and wasn't changed in session A or B
  1285. AAA - value from session A, session B kept it
  1286. BBB - value from session B
  1287. BOTH - value from session B, value from session A is lost
  1288. *viminfo-timestamp*
  1289. For some items a timestamp is used to keep the last changed version. Here it
  1290. doesn't matter in which sequence Vim sessions exit, the newest item(s) are
  1291. always kept. This is used for:
  1292. - The command line history.
  1293. - The search string history.
  1294. - The input-line history.
  1295. - Contents of non-empty registers.
  1296. - The jump list
  1297. - File marks
  1298. The timestamp feature was added before Vim 8.0. Older versions of Vim,
  1299. starting with 7.4.1131, will keep the items with timestamp, but not use them.
  1300. Thus when using both an older and a newer version of Vim the most recent data
  1301. will be kept.
  1302. Notes for Unix:
  1303. - The file protection for the viminfo file will be set to prevent other users
  1304. from being able to read it, because it may contain any text or commands that
  1305. you have worked with.
  1306. - If you want to share the viminfo file with other users (e.g. when you "su"
  1307. to another user), you can make the file writable for the group or everybody.
  1308. Vim will preserve this when replacing the viminfo file. Be careful, don't
  1309. allow just anybody to read and write your viminfo file!
  1310. - Vim will not overwrite a viminfo file that is not writable by the current
  1311. "real" user. This helps for when you did "su" to become root, but your
  1312. $HOME is still set to a normal user's home directory. Otherwise Vim would
  1313. create a viminfo file owned by root that nobody else can read.
  1314. - The viminfo file cannot be a symbolic link. This is to avoid security
  1315. issues.
  1316. Marks are stored for each file separately. When a file is read and 'viminfo'
  1317. is non-empty, the marks for that file are read from the viminfo file. NOTE:
  1318. The marks are only written when exiting Vim, which is fine because marks are
  1319. remembered for all the files you have opened in the current editing session,
  1320. unless ":bdel" is used. If you want to save the marks for a file that you are
  1321. about to abandon with ":bdel", use ":wv". The '[' and ']' marks are not
  1322. stored, but the '"' mark is. The '"' mark is very useful for jumping to the
  1323. cursor position when the file was last exited. No marks are saved for files
  1324. that start with any string given with the "r" flag in 'viminfo'. This can be
  1325. used to avoid saving marks for files on removable media (for MS-Windows you
  1326. would use "ra:,rb:", for Amiga "rdf0:,rdf1:,rdf2:").
  1327. The |v:oldfiles| variable is filled with the file names that the viminfo file
  1328. has marks for.
  1329. *viminfo-file-marks*
  1330. Uppercase marks ('A to 'Z) are stored when writing the viminfo file. The
  1331. numbered marks ('0 to '9) are a bit special. When the viminfo file is written
  1332. (when exiting or with the ":wviminfo" command), '0 is set to the current cursor
  1333. position and file. The old '0 is moved to '1, '1 to '2, etc. This
  1334. resembles what happens with the "1 to "9 delete registers. If the current
  1335. cursor position is already present in '0 to '9, it is moved to '0, to avoid
  1336. having the same position twice. The result is that with "'0", you can jump
  1337. back to the file and line where you exited Vim. To do that right away, try
  1338. using this command: >
  1339. vim -c "normal '0"
  1340. In a csh compatible shell you could make an alias for it: >
  1341. alias lvim vim -c '"'normal "'"0'"'
  1342. For a bash-like shell: >
  1343. alias lvim='vim -c "normal '\''0"'
  1344. Use the "r" flag in 'viminfo' to specify for which files no marks should be
  1345. remembered.
  1346. VIMINFO FILE NAME *viminfo-file-name*
  1347. - The default name of the viminfo file is "$HOME/.viminfo" for Unix,
  1348. "s:.viminfo" for Amiga, "$HOME\_viminfo" for Win32. For Win32, when $HOME
  1349. is not set, "$VIM\_viminfo" is used. When $VIM is also not set,
  1350. "c:\_viminfo" is used.
  1351. - The 'n' flag in the 'viminfo' option can be used to specify another viminfo
  1352. file name |'viminfo'|.
  1353. - The "-i" Vim argument can be used to set another file name, |-i|. When the
  1354. file name given is "NONE" (all uppercase), no viminfo file is ever read or
  1355. written. Also not for the commands below!
  1356. - The 'viminfofile' option can be used like the "-i" argument. In fact, the
  1357. value from the "-i" argument is stored in the 'viminfofile' option.
  1358. - For the commands below, another file name can be given, overriding the
  1359. default and the name given with 'viminfo' or "-i" (unless it's NONE).
  1360. CHARACTER ENCODING *viminfo-encoding*
  1361. The text in the viminfo file is encoded as specified with the 'encoding'
  1362. option. Normally you will always work with the same 'encoding' value, and
  1363. this works just fine. However, if you read the viminfo file with another
  1364. value for 'encoding' than what it was written with, some of the text
  1365. (non-ASCII characters) may be invalid. If this is unacceptable, add the 'c'
  1366. flag to the 'viminfo' option: >
  1367. :set viminfo+=c
  1368. Vim will then attempt to convert the text in the viminfo file from the
  1369. 'encoding' value it was written with to the current 'encoding' value. This
  1370. requires Vim to be compiled with the |+iconv| feature. Filenames are not
  1371. converted.
  1372. MANUALLY READING AND WRITING *viminfo-read-write*
  1373. Two commands can be used to read and write the viminfo file manually. This
  1374. can be used to exchange registers between two running Vim programs: First
  1375. type ":wv" in one and then ":rv" in the other. Note that if the register
  1376. already contained something, then ":rv!" would be required. Also note
  1377. however that this means everything will be overwritten with information from
  1378. the first Vim, including the command line history, etc.
  1379. The viminfo file itself can be edited by hand too, although we suggest you
  1380. start with an existing one to get the format right. It is reasonably
  1381. self-explanatory once you're in there. This can be useful in order to
  1382. create a second file, say "~/.my_viminfo" which could contain certain
  1383. settings that you always want when you first start Vim. For example, you
  1384. can preload registers with particular data, or put certain commands in the
  1385. command line history. A line in your .vimrc file like >
  1386. :rviminfo! ~/.my_viminfo
  1387. can be used to load this information. You could even have different viminfos
  1388. for different types of files (e.g., C code) and load them based on the file
  1389. name, using the ":autocmd" command (see |:autocmd|).
  1390. *viminfo-errors*
  1391. When Vim detects an error while reading a viminfo file, it will not overwrite
  1392. that file. If there are more than 10 errors, Vim stops reading the viminfo
  1393. file. This was done to avoid accidentally destroying a file when the file
  1394. name of the viminfo file is wrong. This could happen when accidentally typing
  1395. "vim -i file" when you wanted "vim -R file" (yes, somebody accidentally did
  1396. that!). If you want to overwrite a viminfo file with an error in it, you will
  1397. either have to fix the error, or delete the file (while Vim is running, so
  1398. most of the information will be restored).
  1399. *:rv* *:rviminfo* *E195*
  1400. :rv[iminfo][!] [file] Read from viminfo file [file] (default: see
  1401. |viminfo-file-name| above).
  1402. If [!] is given, then any information that is
  1403. already set (registers, marks, |v:oldfiles|, etc.)
  1404. will be overwritten
  1405. *:wv* *:wviminfo* *E137* *E138* *E574* *E886* *E929*
  1406. :wv[iminfo][!] [file] Write to viminfo file [file] (default: see
  1407. |viminfo-file-name| above).
  1408. This command has no effect when 'viminfofile' has been
  1409. set to "NONE".
  1410. The information in the file is first read in to make
  1411. a merge between old and new info. When [!] is used,
  1412. the old information is not read first, only the
  1413. internal info is written. If 'viminfo' is empty, marks
  1414. for up to 100 files will be written.
  1415. When you get error "E929: Too many viminfo temp files"
  1416. check that no old temp files were left behind (e.g.
  1417. ~/.viminf*) and that you can write in the directory of
  1418. the .viminfo file.
  1419. *:ol* *:oldfiles*
  1420. :ol[dfiles] List the files that have marks stored in the viminfo
  1421. file. This list is read on startup and only changes
  1422. afterwards with `:rviminfo!`. Also see |v:oldfiles|.
  1423. The number can be used with |c_#<|.
  1424. The output can be filtered with |:filter|, e.g.: >
  1425. filter /\.vim/ oldfiles
  1426. < The filtering happens on the file name.
  1427. {only when compiled with the |+eval| feature}
  1428. :bro[wse] ol[dfiles][!]
  1429. List file names as with |:oldfiles|, and then prompt
  1430. for a number. When the number is valid that file from
  1431. the list is edited.
  1432. If you get the |press-enter| prompt you can press "q"
  1433. and still get the prompt to enter a file number.
  1434. Use ! to abandon a modified buffer. |abandon|
  1435. {not when compiled with tiny or small features}
  1436. vim:tw=78:ts=8:noet:ft=help:norl: