home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / mac / vim55rt.sit / runtime / doc / starting.txt < prev    next >
Encoding:
Text File  |  1999-09-25  |  49.6 KB  |  1,186 lines  |  [TEXT/MPS ]

  1. *starting.txt*  For Vim version 5.5.  Last change: 1999 Sep 07
  2.  
  3.  
  4.           VIM REFERENCE MANUAL    by Bram Moolenaar
  5.  
  6.  
  7. Starting Vim                        *starting*
  8.  
  9. 1. Vim arguments        |vim-arguments|
  10. 2. Vim on the Amiga        |starting-amiga|
  11. 3. Running Vim from xargs    |xargs|
  12. 4. Initialization        |initialization|
  13. 5. Suspending            |suspend|
  14. 6. The vimrc file        |vimrc-intro|
  15. 7. The viminfo file        |viminfo-file|
  16.  
  17. ==============================================================================
  18. 1. Vim arguments                    *vim-arguments*
  19.  
  20. Most often, Vim is started to edit a single file with the command
  21.  
  22.     vim filename                    *-vim*
  23.  
  24. More generally, Vim is started with:
  25.  
  26.     vim [option | filename] ..
  27.  
  28. Option arguments and file name arguments can be mixed, and any number of them
  29. can be given.  However, watch out for options that take an argument.
  30.  
  31. For compatibility with various Vi versions, see    |cmdline-arguments|.
  32.  
  33. Exactly one out of the following five items may be used to choose how to
  34. start editing:
  35.  
  36.                             *-file* *---*
  37. filename    One or more file names.  The first one will be the current
  38.         file and read into the buffer.  The cursor will be positioned
  39.         on the first line of the buffer.
  40.         To avoid a file name starting with a '-' being interpreted as
  41.         an option, precede the arglist with "--", e.g.:
  42.             Vim -- -filename
  43.         All arguments after the "--" will be interpreted as file names,
  44.         no other options or "+command" argument can follow.
  45.  
  46.                             *--*
  47. -        This argument can mean two things, depending on whether Ex
  48.         mode is to be used.
  49.  
  50.         Starting in Normal mode:
  51. >    vim -   or  ex -v -
  52.         Start editing a new buffer, which is filled with text
  53.         that is read from stdin.  The commands that would normally be
  54.         read from stdin will now be read from stderr.  Example:
  55. >            find . -name "*.c" -print | vim -
  56.         The buffer will be marked modified, because it contains text
  57.         that needs to be saved.  Except when in readonly mode, then
  58.         the buffer is not marked modified.  Example:
  59. >            ls | view -
  60.  
  61.         Starting in Ex mode:
  62. >    ex -    or   vim -e -
  63.         Start editing in silent mode.  See |-s-ex|.
  64.  
  65.                             *-t* *-tag*
  66. -t {tag}    A tag.  "tag" is looked up in the tags file, the associated
  67.         file becomes the current file, and the associated command is
  68.         executed.  Mostly this is used for C programs, in which case
  69.         "tag" often is a function name.  The effect is that the file
  70.         containing that function becomes the current file and the
  71.         cursor is positioned on the start of the function (see
  72.         |tags|).
  73.  
  74.                             *-q* *-qf*
  75. -q [errorfile]    QuickFix mode.  The file with the name [errorfile] is read
  76.         and the first error is displayed.  See |quickfix|.
  77.         If [errorfile] is not given, the 'errorfile' option is used
  78.         for the file name.  See 'errorfile' for the default value.
  79.         {not in Vi}
  80.  
  81. (nothing)    Without one of the four items above, Vim will start editing a
  82.         new buffer.  It's empty and doesn't have a file name.
  83.  
  84.  
  85. The startup mode can be changed by using another name instead of "vim", which
  86. is equal to giving options:
  87. ex    vim -e        Start in Ex mode (see |Ex-mode|).            *ex*
  88. view    vim -R        Start in read-only mode (see |-R|).            *view*
  89. gvim    vim -g        Start the GUI (see |gui|).                *gvim*
  90. gex    vim -eg        Start the GUI in Ex mode.                *gex*
  91. gview    vim -Rg        Start the GUI in read-only mode.            *gview*
  92. rvim    vim -Z        Like "vim", but in restricted mode (see |-Z|)   *rvim*
  93. rview    vim -RZ        Like "view", but in restricted mode.        *rview*
  94. rgvim    vim -gZ        Like "gvim", but in restricted mode.        *rgvim*
  95. rgview    vim -RgZ    Like "gview", but in restricted mode.        *rgview*
  96.  
  97. Additional characters may follow, they are ignored.  For example, you can have
  98. "gvim-5" to start the GUI.  You must have an executable by that name then, of
  99. course.
  100.  
  101. On Unix, you would normally have one executable called Vim, and links from the
  102. different startup-names to that executable.  If your system does not support
  103. links and you do not want to have several copies of the executable, you could
  104. use an alias instead.  For example:
  105. >    alias view   vim -R
  106. >    alias gvim   vim -g
  107.  
  108.                             *startup-options*
  109. The option arguments may be given in any order.  Single-letter options can be
  110. combined after one dash.  There can be no option arguments after the "--"
  111. argument.
  112.  
  113. --help                            *-h* *--help*
  114. -h        Give usage (help) message and exit.  {not in Vi}
  115.  
  116.                             *--version*
  117. --version    Print version information and exit.  Same output as for
  118.         |:version| command.  {not in Vi}
  119.  
  120.                             *-+*
  121. +[num]        The cursor will be positioned on line "num" for the first
  122.         file being edited.  If "num" is missing, the cursor will be
  123.         positioned on the last line.
  124.  
  125.                             *-+/*
  126. +/{pat}        The cursor will be positioned on the first line containing
  127.         "pat" in the first file being edited (see |pattern| for the
  128.         available search patterns).
  129.  
  130. +{command}                        *-+c* *-c*
  131. -c {command}    "command" will be executed after the first file has been
  132.         read (and after autocommands and modelines for that file have
  133.         been processed).  "command" is interpreted as an Ex command.
  134.         If the "command" contains spaces, it must be enclosed in
  135.         double quotes (this depends on the shell that is used).
  136.         Example:
  137. >            vim  "+set si"  main.c
  138. >            vim  -c "set ff=dos"  -c wq  mine.mak
  139.  
  140.         Note: You can use up to 10 "+" or "-c" arguments in a Vim
  141.         command.  They are executed in the order given. {Vi only
  142.         allows one command}
  143.  
  144.                             *-r*
  145. -r        Recovery mode.  Without a file name argument, a list of
  146.         existing swap files is given.  With a file name, a swap file
  147.         is read to recover a crashed editing session.  See
  148.         |crash-recovery|.
  149.  
  150.                             *-L*
  151. -L        Same as -r.  {only in some versions of Vi: "List recoverable
  152.         edit sessions"}
  153.  
  154.                             *-R*
  155. -R        Readonly mode.  The 'readonly' option will be set for all the
  156.         files being edited.  You can still edit the buffer, but will
  157.         be prevented from accidentally overwriting a file.  If you
  158.         forgot that you are in View mode and did make some changes,
  159.         you can overwrite a file by adding an exclamation mark to
  160.         the Ex command, as in ":w!".  The 'readonly' option can be
  161.         reset with ":set noro" (see the options chapter, |options|).
  162.         Subsequent edits will not be done in readonly mode.  Calling
  163.         the executable "view" has the same effect as the -R argument.
  164.         The 'updatecount' option will be set to 10000, meaning that
  165.         the swap file will not be updated automatically very often.
  166.  
  167.                             *-m*
  168. -m        Modifications not allowed.  The 'write' option will be reset,
  169.         so that writing files is disabled.  The 'write' option can be
  170.         set to enable writing again.
  171.  
  172.                             *-Z*
  173. -Z        Restricted mode.  All commands that make use of an external
  174.         shell are disabled.  This includes suspending with CTRL-Z,
  175.         ":sh", filtering, etc.
  176.  
  177.                             *-g*
  178. -g        Start Vim in GUI mode.  See |gui|.
  179.  
  180.                             *-v*
  181. -v        Start Ex in Vi mode.  Only makes a difference when the
  182.         executable is called "ex" or "gvim".  For gvim the GUI is not
  183.         started if possible.
  184.  
  185.                             *-e*
  186. -e        Start Vim in Ex mode.  Only makes a difference when the
  187.         executable is not called "ex".
  188.  
  189.                             *-s-ex*
  190. -s        Silent or batch mode.  Only when Vim was started as "ex" or
  191.         when preceded with the "-e" argument.  Otherwise see |-s|.
  192.         To be used when Vim is used to execute Ex commands from a file
  193.         instead of a terminal.  Switches off most prompts and
  194.         informative messages.  But not warning and error messages, and
  195.         the output from commands that print text lines, like ":print"
  196.         and ":list".
  197.         Initializations are skipped (except the ones given with the
  198.         "-u" argument).
  199.  
  200.                             *-b*
  201. -b        Binary mode.  File I/O will only recognize <NL> to separate
  202.         lines. The 'expandtab' option will be reset.  The 'textwidth'
  203.         option is set to 0.  'modeline' is reset.  The 'binary' option
  204.         is set.  This is done after reading the vimrc/exrc files but
  205.         before reading any file in the arglist.  See also
  206.         |edit-binary|.  {not in Vi}
  207.  
  208.                             *-l*
  209. -l        Lisp mode.  Sets the 'lisp' and 'showmatch' options on.
  210.  
  211.                             *-F*
  212. -F        Farsi mode.  Sets the 'fkmap' and 'rightleft' options on.
  213.         (Only when compiled with |+rightleft| and |+farsi| features,
  214.         otherwise Vim gives an error message and exits).  {not in Vi}
  215.  
  216.                             *-H*
  217. -H        Hebrew mode.  Sets the 'hkmap' and 'rightleft' options on.
  218.         (Only when compiled with the |+rightleft| feature, otherwise
  219.         Vim gives an error message and exits).  {not in Vi}
  220.  
  221.                             *-V* *verbose*
  222. -V[n]        Verbose.  Sets the 'verbose' option to [n][ (default: 10).
  223.         Messages will be given for each file that is ":source"d and
  224.         for reading or writing a viminfo file.  Can be used to find
  225.         out what is happening upon startup and exit.  {not in Vi}
  226.  
  227.                             *-C*
  228. -C        Compatible mode.  Sets the 'compatible' option.  You can use
  229.         this to get 'compatible', even though there is a .vimrc file.
  230.         Also see |compatible-default|.  {not in Vi}
  231.  
  232.                             *-N*
  233. -N        Not compatible mode.  Resets the 'compatible' option.  You can
  234.         use this to get 'nocompatible', when there is no .vimrc file.
  235.         Also see |compatible-default|.  {not in Vi}
  236.  
  237.                             *-n*
  238. -n        No swap file will be used.  Recovery after a crash will be
  239.         impossible.  Handy if you want to view or edit a file on a
  240.         very slow medium (e.g., a floppy).
  241.         Can also be done with ":set updatecount=0".  You can switch it
  242.         on again by setting the 'updatecount' option to some value,
  243.         e.g., ":set uc=100".
  244.         'updatecount' is set to 0 AFTER executing commands from a
  245.         vimrc file, but before the GUI initializations.  Thus it
  246.         overrides a setting for 'updatecount' in a vimrc file, but not
  247.         in a gvimrc file.  See |startup|.  {not in Vi}
  248.         When you want to reduce accesses to the disk (e.g., for a
  249.         laptop), don't use "-n", but set 'updatetime' and
  250.         'udpatecount' to very big numbers, and type ":preserve" when
  251.         you want to save your work.  This way you keep the possibility
  252.         for crash recovery.
  253.  
  254.                             *-o*
  255. -o[N]        Open N windows.  If [N] is not given, one window is opened
  256.         for every file given as argument.  If there is not enough
  257.         room, only the first few files get a window.  If there are
  258.         more windows than arguments, the last few windows will be
  259.         editing an empty file.  {not in Vi}
  260.  
  261.                             *-T*
  262. -T {terminal}    Set the terminal type to "terminal".  This influences the
  263.         codes that Vim will send to your terminal.  This is normally
  264.         not needed, because Vim will be able to find out what type
  265.         of terminal you are using (See |terminal-info|).  {not in Vi}
  266.  
  267.                             *-d*
  268. -d {device}    Amiga only: The "device" is opened to be used for editing.
  269.         Normally you would use this to set the window position and
  270.         size: "-d con:x/y/width/height", e.g.,
  271.         "-d con:30/10/600/150".  But you can also use it to start
  272.         editing on another device, e.g., AUX:.  {not in Vi}
  273.  
  274.                             *-f*
  275. -f        Amiga: Do not restart Vim to open a new window.  This
  276.         option should be used when Vim is started by a program that
  277.         will wait for the edit session to finish (e.g., mail or
  278.         readnews).  See |amiga-window|.  {not in Vi}
  279.  
  280.         GUI: Do not disconnect from the program that started Vim.
  281.         'f' stands for "foreground".  If omitted, the GUI forks a new
  282.         process and exits the current one.  "-f" should be used when
  283.         gvim is started by a program that will wait for the edit
  284.         session to finish (e.g., mail or readnews).  If you want gvim
  285.         never to fork, include 'f' in 'guioptions' in your .gvimrc.
  286.         Careful: You can use "-gf" to start the GUI in the foreground,
  287.         but "-fg" is used to specify the foreground color.  {not in
  288.         Vi} |gui-fork|
  289.  
  290.                             *-u*
  291. -u {vimrc}    The file "vimrc" is read for initializations.  Other
  292.         initializations are skipped; see |initialization|.  This can
  293.         be used to start Vim in a special mode, with special
  294.         mappings and settings.  A shell alias can be used to make
  295.         this easy to use.  For example:
  296. >            alias vimc vim -u ~/.c_vimrc !*
  297.         Also consider using autocommands; see |autocommand|.
  298.         When {vimrc} is equal to "NONE" (all uppercase), all
  299.         initializations from files and environment variables are
  300.         skipped, including reading the .gvimrc file when the GUI
  301.         starts.
  302.         Using the "-u" argument also means that the 'compatible'
  303.         option will be on by default.  This can have unexpected side
  304.         effects.  See |'compatible'|.
  305.         {not in Vi}
  306.  
  307.                             *-U*
  308. -U {gvimrc}    The file "gvimrc" is read for initializations when the GUI
  309.         starts.  Other GUI initializations are skipped. When {gvimrc}
  310.         is equal to "NONE", no file is read for initializations at
  311.         all.
  312.         Exception: Reading the system-wide menu file is always done.
  313.  
  314.                             *-i*
  315. -i {viminfo}    The file "viminfo" is used instead of the default viminfo
  316.         file.  If the name "NONE" is used (all uppercase), no viminfo
  317.         file is read or written, even if 'viminfo' is set or when
  318.         ":rv" or ":wv" are used.  See also |viminfo-file|.  {not in Vi}
  319.  
  320.                             *-x*
  321. -x        Use encryption to read/write files.  Will prompt for a key,
  322.         which is then stored in the 'key' option.  All writes will
  323.         then use this key to encrypt the text.  The '-x' argument is
  324.         not needed when reading a file, because there is a check if
  325.         the file that is being read has been encrypted, and Vim asks
  326.         for a key automatically. |encryption|
  327.  
  328.                             *-s*
  329. -s {scriptin}    The script file "scriptin" is read.  The characters in the
  330.         file are interpreted as if you had typed them.  The same can
  331.         be done with the command ":source! {scriptin}".  If the end
  332.         of the file is reached before the editor exits, further
  333.         characters are read from the keyboard.  Only works when not
  334.         started in Ex mode, see |-s-ex|.  See also |complex-repeat|.
  335.         {not in Vi}
  336.  
  337.                             *-w*
  338. -w {scriptout}    All the characters that you type are recorded in the file
  339.         "scriptout", until you exit Vim.  This is useful if you want
  340.         to create a script file to be used with "vim -s" or
  341.         ":source!".  When the "scriptout" file already exists, new
  342.         characters are appended.  See also |complex-repeat|.  {not in
  343.         Vi}
  344.  
  345.                             *-W*
  346. -W {scriptout}    Like -w, but do not append, overwrite an existing file.  {not
  347.         in Vi}
  348.  
  349.                             *-w_nr*
  350. -w{number}    Does nothing.  This was included for Vi-compatibility.  In Vi
  351.         it sets the 'window' option, which is not implemented in Vim.
  352.  
  353. Example for using a script file to change a name in several files:
  354.     Create a file "subs.vi" containing substitute commands and a :wq
  355.     command:
  356. >        :%s/Jones/Smith/g
  357. >        :%s/Allen/Peter/g
  358. >        :wq
  359.  
  360.     Execute Vim on all files you want to change:
  361.  
  362. >        foreach i ( *.let ) vim -s subs.vi $i
  363.  
  364. If the executable is called "view", Vim will start in Readonly mode.  This is
  365. useful if you can make a hard or symbolic link from "view" to "vim".
  366. Starting in Readonly mode can also be done with "vim -R".
  367.  
  368. If the executable is called "ex", Vim will start in "Ex" mode.  This means it
  369. will accept only ":" commands.  But when the "-v" argument is given, Vim will
  370. start in in Normal mode anyway.
  371.  
  372. ==============================================================================
  373. 2. Vim on the Amiga                    *starting-amiga*
  374.  
  375. Starting Vim from the Workbench                *workbench*
  376. -------------------------------
  377.  
  378. Vim can be started from the Workbench by clicking on its icon twice.  It will
  379. then start with an empty buffer.
  380.  
  381. Vim can be started to edit one or more files by using a "Project" icon.  The
  382. "Default Tool" of the icon must be the full pathname of the Vim executable.
  383. The name of the ".info" file must be the same as the name of the text file.
  384. By clicking on this icon twice, Vim will be started with the file name as
  385. current file name, which will be read into the buffer (if it exists).  You can
  386. edit multiple files by pressing the shift key while clicking on icons, and
  387. clicking twice on the last one.  The "Default Tool" for all these icons must
  388. be the same.
  389.  
  390. It is not possible to give arguments to Vim, other than file names, from the
  391. workbench.
  392.  
  393. Vim window                        *amiga-window*
  394. ----------
  395.  
  396. Vim will run in the CLI window where it was started.  If Vim was started with
  397. the "run" or "runback" command, or if Vim was started from the workbench, it
  398. will open a window of its own.
  399.  
  400. Technical detail:
  401.     To open the new window a little trick is used.  As soon as Vim
  402.     recognizes that it does not run in a normal CLI window, it will
  403.     create a script file in "t:".  This script file contains the same
  404.     command as the one Vim was started with, and an "endcli" command.
  405.     This script file is then executed with a "newcli" command (the "c:run"
  406.     and "c:newcli" commands are required for this to work).  The script
  407.     file will hang around until reboot, or until you delete it.  This
  408.     method is required to get the ":sh" and ":!" commands to work
  409.     correctly.  But when Vim was started with the -f option (foreground
  410.     mode), this method is not used.  The reason for this is that
  411.     when a program starts Vim with the -f option it will wait for Vim to
  412.     exit.  With the script trick, the calling program does not know when
  413.     Vim exits.  The -f option can be used when Vim is started by a mail
  414.     program which also waits for the edit session to finish.  As a
  415.     consequence, the ":sh" and ":!" commands are not available when the
  416.     -f option is used.
  417.  
  418. Vim will automatically recognize the window size and react to window
  419. resizing.  Under Amiga DOS 1.3, it is advised to use the fastfonts program,
  420. "FF", to speed up display redrawing.
  421.  
  422. ==============================================================================
  423. 3. Running Vim from xargs                    *xargs*
  424.  
  425. The xargs program can be used to start a program with arguments that come from
  426. stdin.  A typical example:
  427.  
  428. >    find . -name "*.c" -print | xargs vim
  429.  
  430. A problem is that stdin for the program run by xargs is not setup properly,
  431. which causes problems for Vim.  That is because Vim expects commands to come
  432. from stdin.  The symptoms are that typed characters are echoed and don't take
  433. effect until <Return> is hit.
  434.  
  435. This is really a problem in xargs.  To work around it, you can use this small
  436. program:
  437.  
  438. > #include <unistd.h>
  439. > #include <stdio.h>
  440. >
  441. > main(argc, argv)
  442. >     int    argc;
  443. >     char   **argv;
  444. > {
  445. >     close(0);        /* close stdin */
  446. >     dup(2);        /* duplicate stdin from stderr */
  447. >     execvp(argv[1], argv + 1);
  448. >     perror("could not execute program");
  449. > }
  450.  
  451. Store this in "start.c", compile it to "start" and put it somewhere in your
  452. search path.  You might have to make a few adjustments for your system.  An
  453. example of using this:
  454.  
  455. >    find . -name "*.c" -print | xargs start vim
  456.  
  457. ==============================================================================
  458. 4. Initialization                *initialization* *startup*
  459.  
  460. This section is about the non-GUI version of Vim.  See |gui-fork| for
  461. additional initialization when starting the GUI.
  462.  
  463. At startup, Vim checks environment variables and files and sets values
  464. accordingly.  Vim proceeds in this order:
  465.  
  466. 1. Set the 'shell' option                *SHELL* *COMSPEC*
  467.     The environment variable SHELL, if it exists, is used to set the
  468.     'shell' option.  On MS-DOS and Win32, the COMPSPEC variable is used
  469.     if SHELL is not set.
  470.  
  471. 2. Set the 'term' option                *TERM*
  472.     The environment variable TERM, if it exists, is used to set the 'term'
  473.     option.
  474.  
  475. 3. Execute Ex commands, from environment variables and/or files
  476.     An environment variable is read as one Ex command line, where multiple
  477.     commands must be separated with '|' or "<NL>".
  478.                                 *vimrc* *exrc*
  479.     A file that contains initialization commands is called a "vimrc" file.
  480.     Each line in a vimrc file is executed as an Ex command line.  It is
  481.     sometimes also referred to as "exrc" file.  They are the same type of
  482.     file, but "exrc" is what Vi always used, "vimrc" is a Vim specific
  483.     name.  Also see |vimrc-intro|.
  484.  
  485.     Recommended place for your personal initializations:
  486.         Unix            $HOME/.vimrc
  487.         OS/2            $HOME/.vimrc or $VIM/.vimrc (or _vimrc)
  488.         MS-DOS and Win32    $HOME/_vimrc or $VIM/_vimrc
  489.         Amiga            s:.vimrc or $VIM/.vimrc
  490.  
  491.     If Vim was started with "-u filename", the file "filename" is used.
  492.     All following initializations until 5. are skipped.
  493.     "vim -u NONE" can be used to skip these initializations.  |-u|
  494.  
  495.     If Vim was started in Ex mode with the "-s" argument, all following
  496.     initializations until 4. are skipped.  Only the "-u" option is
  497.     interpreted.
  498.                                  *system-vimrc*
  499.      a. For Unix, OS/2, VMS, Macintosh, RISC-OS and Amiga the system vimrc
  500.     file is read for initializations.  The path of this file is shown with
  501.     the ":version" command.  Note that this file is ALWAYS read in
  502.     'compatible' mode, since the automatic resetting of 'compatible' is
  503.     only done later.  Add a ":set nocp" command if you like.
  504.  
  505.               *VIMINIT* *.vimrc* *_vimrc* *EXINIT* *.exrc* *_exrc*
  506.      b. Four places are searched for initializations.  The first that exists
  507.     is used, the others are ignored.
  508.     -  The environment variable VIMINIT (see also |compatible-default|) (*)
  509.     -  The user vimrc file(s):
  510.             "$HOME/.vimrc"    (for Unix and OS/2) (*)
  511.             "s:.vimrc"        (for Amiga) (*)
  512.             "home:.vimrc"    (for Amiga) (*)
  513.             "$VIM/.vimrc"    (for OS/2 and Amiga) (*)
  514.             "$HOME/_vimrc"    (for MS-DOS and Win32) (*)
  515.             "$VIM\_vimrc"    (for MS-DOS and Win32) (*)
  516.         Note: For Unix, OS/2 and Amiga, when ".vimrc" does not exist,
  517.         "_vimrc" is also tried, in case an MS-DOS compatible file
  518.         system is used.  For MS-DOS and Win32 ".vimrc" is checked
  519.         after "_vimrc", in case long file names are used.
  520.         Note: For MS-DOS and Win32, "$HOME" is checked first.  If no
  521.         "_vimrc" or ".vimrc" is found there, "$VIM" is tried.
  522.         See |$VIM| for when $VIM is not set.
  523.     -  The environment variable EXINIT
  524.     -  The user exrc file(s).  Same as for the user vimrc file, but with
  525.        "vimrc" replaced by "exrc".  But without the (*)!
  526.  
  527.      c. If the 'exrc' option is on (which is not the default), the current
  528.     directory is searched for four files.  The first that exists is used,
  529.     the others are ignored.
  530.     -  The file ".vimrc" (for Unix, Amiga and OS/2) (*)
  531.             "_vimrc" (for MS-DOS and Win32) (*)
  532.     -  The file "_vimrc" (for Unix, Amiga and OS/2) (*)
  533.             ".vimrc" (for MS-DOS and Win32) (*)
  534.     -  The file ".exrc"  (for Unix, Amiga and OS/2)
  535.             "_exrc"  (for MS-DOS and Win32)
  536.     -  The file "_exrc"  (for Unix, Amiga and OS/2)
  537.             ".exrc"  (for MS-DOS and Win32)
  538.  
  539.      (*) Using this file or environment variable will cause 'compatible' to be
  540.      off by default.  See |compatible-default|.
  541.  
  542. 4. Load the default file type detection script.
  543.     This script is used to set autocommands for the FileType event.  See
  544.     |FileType| and |'filetype'|.  This is only done if Vim was compiled
  545.     with the |+autocmd| feature.
  546.     If Vim was started with "-u filename", this is skipped.  |-u|
  547.     The name of this file depends on the system:
  548.         Amiga        $VIMRUNTIME/filetype.vim
  549.         Mac        $VIMRUNTIME:filetype.vim
  550.         MS-DOS        $VIMRUNTIME\filetype.vim
  551.         RiscOS        Vim:Filetype
  552.         Unix        $VIMRUNTIME/filetype.vim
  553.         VMS        $VIMRUNTIME/filetype.vim
  554.  
  555. 5. Set 'shellpipe' and 'shellredir'
  556.     The 'shellpipe' and 'shellredir' options are set according to the
  557.     value of the 'shell' option, unless they have been set before.
  558.     This means that Vim will figure out the values of 'shellpipe' and
  559.     'shellredir' for you, unless you have set them yourself.
  560.  
  561. 6. Set 'updatecount' to zero, if "-n" command argument used
  562.  
  563. 7. Set binary options
  564.     If the "-b" flag was given to Vim, the options for binary editing will
  565.     be set now.  See |-b|.
  566.  
  567. 8. Perform GUI initializations
  568.     Only when starting "gvim", the GUI initializations will be done.  See
  569.     |gui-init|.
  570.  
  571. 9. Read the viminfo file
  572.     If the 'viminfo' option is not empty, the viminfo file is read.  The
  573.     default is empty, so 'viminfo' must have been set by one of the
  574.     previous initializations.  See |viminfo-file|.
  575.  
  576. 10. Read the quickfix file
  577.     If the "-q" flag was given to Vim, the quickfix file is read.  If this
  578.     fails, Vim exits.
  579.  
  580. 11. Open all windows
  581.     When the |-o| flag was given, windows will be opened (but not
  582.     displayed yet).
  583.     When switching screens, it happens now.  Redrawing starts.
  584.     If the "-q" flag was given to Vim, the first error is jumped to.
  585.     Buffers for all windows will be loaded.
  586.  
  587. 12. Execute startup commands
  588.     If a "-t" flag was given to Vim, the tag is jumped to.
  589.     The commands given with the |-c| and |+cmd| arguments are executed.
  590.     If the 'insertmode' option is set, Insert mode is entered.
  591.     The |VimEnter| autocommands are executed.
  592.  
  593. Some hints on using initializations:
  594.  
  595. Standard setup:
  596. Create a vimrc file to set the default settings and mappings for all your edit
  597. sessions.  Put it in a place so that it will be found by 3b:
  598.     ~/.vimrc    (Unix and OS/2)
  599.     s:.vimrc    (Amiga)
  600.     $VIM\_vimrc    (MS-DOS and Win32)
  601. Note that creating a vimrc file will cause the 'compatible' option to be off
  602. by default.  See |compatible-default|.
  603.  
  604. Local setup:
  605. Put all commands that you need for editing a specific directory only into a
  606. vimrc file and place it in that directory under the name ".vimrc" ("_vimrc"
  607. for MS-DOS and Win32).  NOTE: To make Vim look for these special files you
  608. have to turn on the option 'exrc'.  See |trojan-horse| too.
  609.  
  610. System setup:
  611. This only applies if you are managing a Unix system with several users and
  612. want to set the defaults for all users.  Create a vimrc file with commands
  613. for default settings and mappings and put it in the place that is given with
  614. the ":version" command.
  615.  
  616. Saving the current state of Vim to a file:
  617. Whenever you have changed values of options or when you have created a
  618. mapping, then you may want to save them in a vimrc file for later use.  See
  619. |save-settings| about saving the current state of settings to a file.
  620.  
  621. Avoiding setup problems for Vi users:
  622. Vi uses the variable EXINIT and the file "~/.exrc".  So if you do not want to
  623. interfere with Vi, then use the variable VIMINIT and the file "vimrc" instead.
  624.  
  625. Amiga environment variables:
  626. On the Amiga, two types of environment variables exist.  The ones set with the
  627. DOS 1.3 (or later) setenv command are recognized.  See the AmigaDos 1.3
  628. manual.  The environment variables set with the old Manx Set command (before
  629. version 5.0) are not recognized.
  630.  
  631. MS-DOS line separators:
  632. On MS-DOS-like systems (MS-DOS itself, Win32, and OS/2), Vim assumes that all
  633. the vimrc files have <CR> <NL> pairs as line separators.  This will give
  634. problems if you have a file with only <NL>s and have a line like
  635. ":map xx yy^M".  The trailing ^M will be ignored.
  636.  
  637.                              *compatible-default*
  638. When Vim starts, the 'compatible' option is on.  This will be used when Vim
  639. starts its initializations.  But as soon as a user vimrc file is found, or a
  640. vimrc file in the current directory, or the "VIMINIT" environment variable is
  641. set, it will be set to 'nocompatible'.  This has the side effect of setting or
  642. resetting other options (see 'compatible').  But only the options that have
  643. not been set or reset will be changed.  This has the same effect like the
  644. value of 'compatible' had this value when starting Vim.  Note that this
  645. doesn't happen for the system-wide vimrc file.
  646.  
  647. But there is a side effect of setting or resetting 'compatible' at the moment
  648. a .vimrc file is found: Mappings are interpreted the moment they are
  649. encountered.  This makes a difference when using things like "<CR>".  If the
  650. mappings depend on a certain value of 'compatible', set or reset it before
  651. giving the mapping.
  652.  
  653. The above behavior can be overridden in these ways:
  654. - If the "-N" command line argument is given, 'nocompatible' will be used,
  655.   even when no vimrc file exists.
  656. - If the "-C" command line argument is given, 'compatible' will be used, even
  657.   when a vimrc file exists.
  658. - If the "-u {vimrc}" argument is used, 'compatible' will be used.
  659. - When the name of the executable ends in "ex", then this works like the "-C"
  660.   argument was given: 'compatible' will be used, even when a vimrc file
  661.   exists.  This has been done to make Vim behave like "ex", when it is started
  662.   as "ex".
  663.  
  664. Avoiding trojan horses:                    *trojan-horse*
  665. While reading the "vimrc" or the "exrc" file in the current directory, some
  666. commands can be disabled for security reasons by setting the 'secure' option.
  667. This is always done when executing the command from a tags file.  Otherwise it
  668. would be possible that you accidentally use a vimrc or tags file that somebody
  669. else created and contains nasty commands.  The disabled commands are the ones
  670. that start a shell, the ones that write to a file, and ":autocmd".  The ":map"
  671. commands are echoed, so you can see which keys are being mapped.
  672.     If you want Vim to execute all commands in a local vimrc file, you
  673. can reset the 'secure' option in the EXINIT or VIMINIT environment variable or
  674. in the global "exrc" or "vimrc" file.  This is not possible in "vimrc" or
  675. "exrc" in the current directory, for obvious reasons.
  676.     On Unix systems, this only happens if you are not the owner of the
  677. vimrc file.  Warning: If you unpack an archive that contains a vimrc or exrc
  678. file, it will be owned by you.  You won't have the security protection.  Check
  679. the vimrc file before you start Vim in that directory, or reset the 'exrc'
  680. option.  Some Unix systems allow a user to do "chown" on a file.  This makes
  681. it possible for another user to create a nasty vimrc and make you the owner.
  682. Be careful!
  683.     When using tag search commands, executing the search command (the last
  684. part of the line in the tags file) is always done in secure mode.  This works
  685. just like executing a command from a vimrc/exrc in the current directory.
  686.  
  687.                             *slow-start*
  688. If Vim takes a long time to start up, there may be a few causes:
  689. - If the Unix version was compiled with the GUI and/or X11 (check the output
  690.   of ":version" for "+GUI" and "+X11"), it may need to load shared libraries
  691.   and connect to the X11 server.  Try compiling a version with GUI and X11
  692.   disabled.  This also should make the executable smaller.
  693. - If you have "viminfo" enabled, the loading of the viminfo file may take a
  694.   while.  You can find out if this is the problem by disabling viminfo for a
  695.   moment (use the Vim argument "-i NONE", |-i|).  Try reducing the number of
  696.   lines stored in a register with ":set viminfo='20\"50".
  697.                             |viminfo-file|.
  698.  
  699.                             *:intro*
  700. When Vim starts without a file name, an introductory message is displayed (for
  701. those who don't know what Vim is).  It is removed as soon as the display is
  702. redrawn in any way.  To see the message again, use the ":intro" command.
  703. To avoid the intro message on startup, add the 'I' flag to 'shortmess'.
  704.  
  705. ==============================================================================
  706. 5. Suspending                        *suspend*
  707.  
  708.                         *iconise* *CTRL-Z* *v_CTRL-Z*
  709. CTRL-Z            Suspend Vim, like ":stop".
  710.             Works in Normal and in Visual mode.  In Insert and
  711.             Command-line mode, the CTRL-Z is inserted as a normal
  712.             character.
  713.  
  714.  
  715. :sus[pend][!]    or            *:sus* *:suspend* *:st* *:stop*
  716. :st[op][!]        Suspend Vim.
  717.             If the '!' is not given and 'autowrite' is set, every
  718.             buffer with changes and a file name is written out.
  719.             If the '!' is given or 'autowrite' is not set, changed
  720.             buffers are not written, don't forget to bring Vim
  721.             back to the foreground later!
  722.  
  723. In the GUI, suspending is implemented as iconising gvim.  In Windows 95/NT,
  724. gvim is minimized.
  725.  
  726. On many Unix systems, it is possible to suspend Vim with CTRL-Z.  This is only
  727. possible in Normal and Visual mode (see next chapter, |vim-modes|).  Vim will
  728. continue if you make it the foreground job again.  On other systems, CTRL-Z
  729. will start a new shell.  This is the same as the ":sh" command.  Vim will
  730. continue if you exit from the shell.
  731.  
  732. ==============================================================================
  733. 6. The vimrc file            *vimrc-intro* *vim-script-intro*
  734.  
  735. A vimrc file can be used for settings you intend to use more-or-less for every
  736. of your Vim sessions.  Normally the file is called $HOME/.vimrc, but other
  737. files can also be used, see |vimrc|.  Vim will read it (them) when starting
  738. and interpret the commands in them.
  739.  
  740. You can also use Vim script files for other purposes.  The files used for
  741. syntax highlighting are an example.  There are enough commands in Vim to
  742. accomplish just about any task.
  743.  
  744.                         *vimrc_example.vim*
  745. You should be able to find an example vimrc file at
  746. $VIMRUNTIME/vimrc_example.vim.  You could use this as a start for your own
  747. vimrc file.  You can also find a lot of examples in vimrc files made by
  748. others.  Have a look at http://www.vim.org/user.html.
  749.  
  750.  
  751. USING EX COMMANDS ~
  752.  
  753. The vimrc file can contain anything that can be typed on the Vim command line.
  754. The recommended practice is not to include the preceding colon sign ":", thus
  755. if one would type
  756. >    :set number
  757. on the Vim command line, the same can appear in the vimrc file simply as
  758. >    set number
  759.  
  760. The end-of-line character depends on the system.  For Unix a single <NL>
  761. character is used.  For MS-DOS, Windows, OS/2 and the like, <CR><LF> is used.
  762. This is important when using mappings that end in a <CR>.  See |:source_crnl|.
  763.  
  764. Long lines can be split up by inserting a "\" (backslash) at the start of
  765. the next line where the line has been broken, see |line-continuation|.
  766. Example:
  767. >    iabbr Http  Hyper Text Transfer
  768. >        \ Protocol
  769. Note that this only works in a Vim script file.
  770.  
  771.  
  772. WHITE SPACE ~
  773.  
  774. Blank lines are allowed and ignored.
  775.  
  776. Leading whitespace characters (blanks and TABs) are always ignored.  The
  777. whitespaces between parameters (e.g. between the 'set' and the 'number' in the
  778. example above) are reduced to one blank character and plays the role of a
  779. separator, the whitespaces after the last (visible) character may or may not
  780. be ignored depending on the situation, see below.
  781.  
  782. For a ":set" command involving the "=" (equal) sign, such as in
  783. >    set cpoptions    =aABceFst
  784. the whitespace immediately before the "=" sign is ignored.  But there can be
  785. no whitespace after the "=" sign!
  786.  
  787. To include a whitespace character in the value of an option, it must be
  788. escaped by a "\" (backslash)  as in the following example:
  789. >    set tags=my\ nice\ file
  790. The same example written as
  791. >    set tags=my nice file
  792. will issue an error, because it is interpreted as:
  793. >    set tags=my
  794. >    set nice
  795. >    set file
  796.  
  797.  
  798. COMMENTS ~
  799.  
  800. The character " (the double quote mark) starts a comment.  Everything after
  801. and including this character until the end-of-line is considered a comment and
  802. is ignored, except for commands that don't consider comments, as shown in
  803. examples below.  A comment can start on any character position on the line.
  804.  
  805. There is a little "catch" with comments for some commands.  Examples:
  806. >    abbrev dev development        " shorthand
  807. >    map <F3> o#include        " insert include
  808. >    execute cmd            " do it
  809. >    !ls *.c                " list C files
  810. The abbreviation 'dev' will be expanded to 'development     " shorthand'.  The
  811. mapping of <F3> will actually be the whole line after the 'o# ....' including
  812. the '" insert include'.  The "execute" command will give an error.  The "!"
  813. command will send everything after it to the shell, causing an error for an
  814. unmatched '"' character.
  815. There can be no comment after ":map", ":abbreviate", ":execute" and "!"
  816. commands (there are a few more commands with this restriction).  For the
  817. "map", ":abbreviate" and "execute" commands there is a trick:
  818. >    abbrev dev development|" shorthand
  819. >    map <F3> o#include|" insert include
  820. >    execute cmd            |" do it
  821. With the '|' character the command is separated from the next one.  And that
  822. next command is only a comment.
  823.  
  824. Note that there is no white space before the '|' in the abbreviation and
  825. mapping.  For these commands, any character until the end-of-line or '|' is
  826. included.  As a consequence of this behavior, you don't always see that
  827. trailing whitespace is included:
  828. >    map <F4> o#include  
  829. To avoid these problems, you can set the 'list' option when editing vimrc
  830. files.
  831.  
  832.  
  833. PITFALLS ~
  834.  
  835. Even bigger problem arises in the following example:
  836. >    map ,ab o#include
  837. >    unmap ,ab
  838. Here the mapping of ,ab will be ',ab', no trailing whitespaces is included.
  839. However, the "unmap" does not end directly with the end-of-line, Vim will try
  840. to unmap ',ab ', which does not exist as a mapped sequence.  An error will be
  841. issued, which is very hard to identify, because the ending whitespace
  842. character on the 'unmap ,ab ' are not visible.
  843.  
  844. And this is exactly the same what happens when one uses a comment after an
  845. 'unmap' command:
  846. >    unmap ,ab     " comment
  847. Here the comment part will be ignored.  However, Vim will try to unmap
  848. ',ab     ', which does not exist,  Deleting the comment as well as all the
  849. whitespaces up the ending 'b' character will cure the problem.
  850.  
  851. Except for the situations as above, it is legal to put a comment on the same
  852. line as the Vim definitions, such as
  853. >    set number    " display line numbers
  854.  
  855.  
  856. NORMAL MODE COMMANDS ~
  857.  
  858. To execute normal mode commands, the |:normal| command can be used.  To avoid
  859. trouble with special characters, use the |:execute| command.  Its argument is
  860. an expression (more about that further down).  Example:
  861. >    exe "normal mxGOA test.\<Esc>`x"
  862. This appends "A test." below the last line in the file and returns the cursor
  863. to where it was.  Note the use of "\<Esc>", which is translated into the
  864. escape character.  To use a backslash or double quote here you have to put a
  865. backslash before it:
  866. >    exe "normal \"aYgg\"aP"
  867. This yanks the current line and puts it above the first line in the file.  To
  868. do this without changing the cursor position and the text displayed in the
  869. window, this has to be extended a bit:
  870. >    exe "normal ma\"aYHmbgg\"aP`bzt`a"
  871. What this does:
  872.     ma        set mark a at cursor position
  873.     "aY        yank current line into register a
  874.     Hmb        go to top line in window and set mark b there
  875.     gg        go to first line in file
  876.     "aP        put the yanked line above it
  877.     `b        go back to top line in display
  878.     zt        position the text in the window as it was before
  879.     `a        go back to saved cursor position
  880.  
  881.  
  882. IF - ELSE - ENDIF ~
  883.  
  884. Sometimes you will want to execute a command only under a certain condition.
  885. The |:if| command can be used for this.  Example:
  886. >    if &term == "xterm"
  887. >      echo "this is an xterm"
  888. >    endif
  889. The argument for the "if" command is an expression.  If this expression
  890. evaluates to true (non-zero), the statements until the "endif" are executed.
  891. If the expression evaluates to zero, these commands are skipped.
  892. The |:echo| command prints its argument, which is also an expression.
  893.  
  894. Many constructions can be used in an expression.  In the example we see this:
  895.     &term        The value of the 'term' option.  A name prepended with
  896.             '&' is the value of the option by that name.
  897.     ==        "equal", compares the strings or numbers on each
  898.             side, and evaluates to true when they are equal.
  899.     "xterm"        A literal string.
  900. For more information about expressions, see |expression|.
  901.  
  902. You can also use "else":
  903. >    if &tabstop != 8
  904. >      echo "tabstop is " . &tabstop
  905. >    else
  906. >      echo "tabstop is OK"
  907. >    endif
  908. Note that a dot is used in the first echo command, to concatenate the literal
  909. string with the value of the 'tabstop' option.  It is automatically converted
  910. from a number to a string, so that it can be concatenated.
  911.  
  912.  
  913. WHILE - ENDWHILE ~
  914.  
  915. To repeat a sequence of commands the |:while| command can be used:
  916. >    let i = 1
  917. >    while i < 10
  918. >      echo i
  919. >      let i = i + 1
  920. >    endwhile
  921. This uses the internal variable "i".  An internal variable is used just like
  922. in many programming languages.  The |:let| command is used to assign a value
  923. to a variable.  The variable need not be declared and can hold a number or a
  924. string.
  925. The statements between the "while" and the "endwhile" are executed nine times.
  926. Note that the variable "i" is incremented with the "let i = i + 1" command.
  927. If you would forget this, the loop would run forever!  Fortunately you can
  928. interrupt it with a CTRL-C (CTRL-Break on DOS).
  929.  
  930.  
  931. BUILTIN FUNCTIONS ~
  932.  
  933. Vim has builtin functions that you can use.  Example:
  934. >    echo exists("did_my_inits")
  935. This will print a one when the variable "did_my_inits" exists, and a zero if
  936. it doesn't exist.
  937. >    if has("gui_running")
  938. >      syntax on
  939. >    endif
  940. This will switch on syntax highlighting if the GUI is started.  The has()
  941. function can be used to check if a certain feature is supported.
  942. >    call append(0, hostname() . " - " . strftime("%Y %b %d"))
  943. This inserts a line with the name of the computer and the current date at the
  944. start of the current buffer.
  945.  
  946. There are many more functions, which can be used to accomplish most things you
  947. would want to do in Vim, which are too complicated to do with normal commands.
  948. See |functions|.
  949.  
  950.  
  951. USER DEFINED FUNCTIONS ~
  952.  
  953. You will often have a number of commands that you use in several places.  You
  954. can define a function for these, and call it where you want.  Example:
  955. >    function My_Func(name)
  956. >      if a:name ==? "john"
  957. >        let s = "Hello "
  958. >      else
  959. >        let s = "I don't know "
  960. >      endif
  961. >      echo s . a:name . "."
  962. >    endfun
  963. Explanation:
  964. The function "My_Func" is defined with one argument.  "a:name" is used to
  965. refer to that argument.  The "==?" operator is used to compare the argument
  966. with "john" while ignoring case.  You could call it like this:
  967. >    call My_Func("John")
  968. >    Hello John.
  969. >    call My_Func("James")
  970. >    I don't know James.
  971.  
  972. Note that the name of a user function always starts with a capital letter.
  973. There can be any number of arguments.  See |:function|.
  974.  
  975.  
  976. PACKAGING ~
  977.  
  978. To avoid your function names to interfere with functions that you get from
  979. others, use this scheme:
  980. - Prepend a unique string before each function name.  I often use an
  981.   abbreviation.  For example, "OW_" is used for the option window functions.
  982. - Put the definition of your functions together in a file.  Set a global
  983.   variable to indicate that the functions have been loaded.  When sourcing the
  984.   file again, first unload the functions.
  985. Example:
  986. >    " This is the XXX package
  987. >
  988. >    if exists("XXX_loaded")
  989. >      delfun XXX_one
  990. >      delfun XXX_two
  991. >    endif
  992. >
  993. >    function XXX_one(a)
  994. >        ... body of function ...
  995. >    endfun
  996. >
  997. >    function XXX_two(b)
  998. >        ... body of function ...
  999. >    endfun
  1000. >
  1001. >    let XXX_loaded = 1
  1002.  
  1003.  
  1004. AUTOCOMMANDS ~
  1005.  
  1006. You might want to set options or define mappings when editing a certain kind
  1007. of file.  Fortunatly, Vim already recognizes a lot of file types.  This is
  1008. used for syntax highlighting, but you can use it for other things too.  You
  1009. need to have syntax enabled |:syn-on|, or use this command:
  1010. >    filetype on
  1011.  
  1012. For example, this autocommand sets the 'cindent' option in a C program file:
  1013. >    au  FileType  c  set cindent
  1014. This autocommand consists of three parts:
  1015.     FileType    the name of the event which is used
  1016.     c        the name of the file type detected
  1017.     set cindent    the command executed when the event happens and the
  1018.             file type is "c"
  1019. See |:autocmd| for more information.
  1020.  
  1021. This works fine for the 'cindent' option, which is local to a buffer.  When
  1022. this is used for defining a mapping, this will not work properly when there
  1023. are two windows.  For example, if you are editing foo.txt in one window and
  1024. foo.c in another, a mapping defined for foo.c will also be used in foo.txt.
  1025. To make the mapping only work in the foo.c file, it needs to be removed as
  1026. soon as the foo.c file is no longer the current buffer.  That can be done in
  1027. this way:
  1028. >    au BufEnter * if &ft == "c" | call CM_map() | endif
  1029. >    au BufLeave * if &ft == "c" | call CM_unmap() | endif
  1030. >    fun CM_map()
  1031. >      set cindent
  1032. >      imap { {<CR> <BS><CR>}<Up><End>
  1033. >    endfun
  1034. >    fun CM_unmap()
  1035. >      iunmap {
  1036. >    endfun
  1037. One function is used here to define the mapping and another to remove it.
  1038. This makes it possible to add more mappings, without changing the
  1039. autocommands.
  1040. The use of functions makes it possible to keep the autocommands short.  With
  1041. the '|' character commands are separated.
  1042. In the ":imap" command the <> codes are used to avoid the need for control
  1043. characters.  This is easy to type and to read back.  The " <BS> is used to
  1044. avoid that the indent is removed when <CR> is typed.
  1045.  
  1046. ==============================================================================
  1047. 7. The viminfo file                    *viminfo-file*
  1048.  
  1049. If you exit Vim and later start it again, you would normally lose a lot of
  1050. information.  The viminfo file can be used to remember that information, which
  1051. enables you to continue where you left off.
  1052.  
  1053. The viminfo file is used to store:
  1054. - The command line history.
  1055. - The search string history.
  1056. - The input-line history.
  1057. - Contents of registers.
  1058. - Marks for several files.
  1059. - File marks, pointing to locations in files.
  1060. - Last search/substitute pattern (for 'n' and '&').
  1061. - The buffer list.
  1062. - Global variables.
  1063.  
  1064. The viminfo file is not supported when the |+viminfo| feature has been
  1065. disabled at compile time.
  1066.  
  1067. You could also use a session file.  The difference is that the viminfo file
  1068. does not depend on what you are working on.  There normally is only one
  1069. viminfo file.  Session files are used to save the state of a specific editing
  1070. session.  You could have several session files, one for each project you are
  1071. working on.  Viminfo and session files together can be used to effectively
  1072. enter Vim and directly start working in your desired setup. |session-file|
  1073.  
  1074.                             *viminfo-read*
  1075. When Vim is started and the 'viminfo' option is non-empty, the contents of
  1076. the viminfo file are read and the info can be used in the appropriate places.
  1077. The marks are not read in at startup (but file marks are).  See
  1078. |initialization| for how to set the 'viminfo' option upon startup.
  1079.  
  1080.                             *viminfo-write*
  1081. When Vim exits and 'viminfo' is non-empty, the info is stored in the viminfo
  1082. file (it's actually merged with the existing one, if one exists).  The
  1083. 'viminfo' option is a string containing information about what info should be
  1084. stored, and contains limits on how much should be stored (see 'viminfo').
  1085.  
  1086. Notes for Unix:
  1087. - The file protection for the viminfo file will be set to prevent other users
  1088.   from being able to read it, because it may contain any text or commands that
  1089.   you have worked with.
  1090. - If you want to share the viminfo file with other users (e.g. when you "su"
  1091.   to another user), you can make the file writable for the group or everybody.
  1092.   Vim will preserve this when writing new viminfo files.  Be careful, don't
  1093.   allow just anybody to read and write your viminfo file!
  1094. - Vim will not overwrite a viminfo file that is not writable by the current
  1095.   "real" user.  This helps for when you did "su" to become root, but your
  1096.   $HOME is still set to a normal user's home directory.  Otherwise Vim would
  1097.   create a viminfo file owned by root that nobody else can read.
  1098.  
  1099. Marks are stored for each file separately.  When a file is read and 'viminfo'
  1100. is non-empty, the marks for that file are read from the viminfo file.  NOTE:
  1101. The marks are only written when exiting Vim, which is fine because marks are
  1102. remembered for all the files you have opened in the current editing session,
  1103. unless ":bdel" is used.  If you want to save the marks for a file that you are
  1104. about to abandon with ":bdel", use ":wv".  The '[' and ']' marks are not
  1105. stored, but the '"' mark is.  The '"' mark is very useful for jumping to the
  1106. cursor position when the file was last exited.  No marks are saved for files
  1107. that start with any string given with the "r" flag in 'viminfo'.  This can be
  1108. used to avoid saving marks for files on removable media (for MS-DOS you would
  1109. use "ra:,rb:", for Amiga "rdf0:,rdf1:,rdf2:").
  1110.  
  1111.                             *viminfo-file-marks*
  1112. Uppercase marks ('A to 'Z) are stored when writing the viminfo file.  The
  1113. numbered marks ('0 to '9) are a bit special.  When the viminfo file is written
  1114. (when exiting or with the ":wviminfo" command), '0 is set to the current cursor
  1115. position and file.  The old '0 is moved to '1, '1 to '2, etc.  This
  1116. resembles what happens with the "1 to "9 delete registers.  If the current
  1117. cursor position is already present in '0 to '9, it is moved to '0, to avoid
  1118. having the same position twice.  The result is that with "'0", you can jump
  1119. back to the file and line where you exited Vim.  To do that right away, try
  1120. using this command:
  1121.  
  1122. >    vim -c "normal '0"
  1123.  
  1124. In (c)sh, you could make an alias for it:
  1125.  
  1126. >    alias lvim vim -c '"'normal "'"0'"'
  1127.  
  1128. Viminfo file name:                    *viminfo-file-name*
  1129. - The default name of the viminfo file is "$HOME/.viminfo" for Unix and OS/2,
  1130.   "s:.viminfo" for Amiga, "$HOME\_viminfo" for MS-DOS and Win32.  For the last
  1131.   two, when $HOME is not set, "$VIM\_viminfo" is used.  When $VIM is also not
  1132.   set, "c:\_viminfo" is used.  For OS/2 "$VIM/.viminfo" is used when $HOME is
  1133.   not set and $VIM is set.
  1134. - The 'n' flag in the 'viminfo' option can be used to specify another viminfo
  1135.   file name |'viminfo'|.
  1136. - The "-i" Vim argument can be used to set another file name, |-i|.  When the
  1137.   file name given is "NONE" (all uppercase), no viminfo file is ever read or
  1138.   written.  Also not for the commands below!
  1139. - For the commands below, another file name can be given, overriding the
  1140.   default and the name given with 'viminfo' or "-i" (unless it's NONE).
  1141.  
  1142. Two commands can be used to read and write the viminfo file manually.  This
  1143. can be used to exchange registers between two running Vim programs: First
  1144. type ":wv" in one and then ":rv" in the other.  Note that if the register
  1145. already contained something, then ":rv!" would be required.  Also note
  1146. however that this means everything will be overwritten with information from
  1147. the first Vim, including the command line history, etc.
  1148.  
  1149. The viminfo file itself can be edited by hand too, although we suggest you
  1150. start with an existing one to get the format right.  It is reasonably
  1151. self-explanatory once you're in there.  This can be useful in order to
  1152. create a second file, say "~/.my_viminfo" which could contain certain
  1153. settings that you always want when you first start Vim.  For example, you
  1154. can preload registers with particular data, or put certain commands in the
  1155. command line history.  A line in your .vimrc file like
  1156. >    rviminfo! ~/.my_viminfo
  1157. can be used to load this information.  You could even have different viminfos
  1158. for different types of files (e.g., C code) and load them based on the file
  1159. name, using the ":autocmd" command (see |:autocmd|).
  1160.  
  1161.                             *viminfo-errors*
  1162. When Vim detects an error while reading a viminfo file, it will not overwrite
  1163. that file.  If there are more than 10 errors, Vim stops reading the viminfo
  1164. file.  This was done to avoid accidentally destroying a file when the file
  1165. name of the viminfo file is wrong.  This could happen when accidentally typing
  1166. "vim -i file" when you wanted "vim -R file" (yes, somebody accidentally did
  1167. that!).  If you want to overwrite a viminfo file with an error in it, you will
  1168. either have to fix the error, or delete the file (while Vim is running, so
  1169. most of the information will be restored).
  1170.  
  1171.                            *:rv* *:rviminfo*
  1172. :rv[iminfo][!] [file]    Read from viminfo file [file] (default: see above).
  1173.             If [!] is given, then any information that is
  1174.             already set (registers, marks, etc.) will be
  1175.             overwritten.  {not in Vi}
  1176.  
  1177.                            *:wv* *:wviminfo*
  1178. :wv[iminfo][!] [file]    Write to viminfo file [file] (default: see above).
  1179.             The information in the file is first read in to make
  1180.             a merge between old and new info.  When [!] is used,
  1181.             the old information is not read first, only the
  1182.             internal info is written.  If 'viminfo' is empty, marks
  1183.             for up to 100 files will be written.  {not in Vi}
  1184.  
  1185.  vim:tw=78:ts=8:sw=8:
  1186.