home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vim53os2.zip / vim-5.3 / doc / starting.txt < prev    next >
Text File  |  1998-08-30  |  39KB  |  853 lines

  1. *starting.txt*  For Vim version 5.3.  Last modification: 1998 Aug 17
  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. Initialization        |initialization|
  12. 4. Suspending            |suspend|
  13. 5. The vimrc file        |vimrc-intro|
  14. 6. The viminfo file        |viminfo-file|
  15.  
  16. ==============================================================================
  17. 1. Vim arguments                    *vim-arguments*
  18.  
  19. Most often, Vim is started to edit a single file with the command
  20.  
  21.     vim filename                    *-vim*
  22.  
  23. More generally, Vim is started with:
  24.  
  25.     vim [option | filename] ..
  26.  
  27. Option arguments and file name arguments can be mixed, and any number of them
  28. can be given.  However, watch out for options that take an argument.
  29.  
  30. For compatibility with various Vi versions, see    |cmdline-arguments|.
  31.  
  32. Exactly one out of the following five items may be used to choose how to
  33. start editing:
  34.  
  35.                             *-file* *---*
  36. filename    One or more file names.  The first one will be the current
  37.         file and read into the buffer.  The cursor will be positioned
  38.         on the first line of the buffer.
  39.         To avoid a file name starting with a '-' being interpreted as
  40.         an option, precede the arglist with "--", e.g.:
  41.             Vim -- -filename
  42.         All arguments after the "--" will be interpreted as file names,
  43.         no other options or "+command" argument can follow.
  44.  
  45.                             *--*
  46. -        Start editing a new buffer, which is filled with text that is
  47.         read from stdin.  The commands that would normally be read
  48.         from stdin will now be read from stderr.  Example:
  49. >            find . -name "*.c" -print | vim -
  50.         The buffer will be marked modified, because it contains text
  51.         that needs to be saved.  Except when in readonly mode, then
  52.         the buffer is not marked modified.  Example:
  53. >            ls | view -
  54.  
  55.                             *-t* *-tag*
  56. -t {tag}    A tag.  "tag" is looked up in the tags file, the associated
  57.         file becomes the current file, and the associated command is
  58.         executed.  Mostly this is used for C programs, in which case
  59.         "tag" often is a function name.  The effect is that the file
  60.         containing that function becomes the current file and the
  61.         cursor is positioned on the start of the function (see
  62.         |tags|).
  63.  
  64.                             *-q* *-qf*
  65. -q [errorfile]    QuickFix mode.  The file with the name [errorfile] is read
  66.         and the first error is displayed.  See |quickfix|.
  67.         If [errorfile] is not given, the 'errorfile' option is used
  68.         for the file name.  See 'errorfile' for the default value.
  69.         {not in Vi}
  70.  
  71. (nothing)    Without one of the four items above, Vim will start editing a
  72.         new buffer.  It's empty and doesn't have a file name.
  73.  
  74.  
  75. The startup mode can be changed by using another name instead of "vim", which
  76. is equal to giving options:
  77. ex    vim -e        Start in Ex mode (see |Ex-mode|).            *ex*
  78. view    vim -R        Start in read-only mode (see |-R|).            *view*
  79. gvim    vim -g        Start the GUI (see |gui|).                *gvim*
  80. gex    vim -eg        Start the GUI in Ex mode.                *gex*
  81. gview    vim -Rg        Start the GUI in read-only mode.            *gview*
  82. rvim    vim -Z        Like "vim", but in restricted mode (see |-Z|)   *rvim*
  83. rview    vim -RZ        Like "view", but in restricted mode.        *rview*
  84. rgvim    vim -gZ        Like "gvim", but in restricted mode.        *rgvim*
  85. rgview    vim -RgZ    Like "gview", but in restricted mode.        *rgview*
  86.  
  87. Additional characters may follow, they are ignored.  For example, you can have
  88. "gvim-5" to start the GUI.  You must have an executable by that name then, of
  89. course.
  90.  
  91. On Unix, you would normally have one executable called Vim, and links from the
  92. different startup-names to that executable.  If your system does not support
  93. links and you do not want to have several copies of the executable, you could
  94. use an alias instead.  For example:
  95. >    alias view   vim -R
  96. >    alias gvim   vim -g
  97.  
  98.                             *startup-options*
  99. The option arguments may be given in any order.  Single-letter options can be
  100. combined after one dash.  There can be no option arguments after the "--"
  101. argument.
  102.  
  103. --help                            *-h* *--help*
  104. -h        Give usage (help) message and exit.  {not in Vi}
  105.  
  106.                             *--version*
  107. --version    Print version information and exit.  Same output as for
  108.         |:version| command.  {not in Vi}
  109.  
  110.                             *-+*
  111. +[num]        The cursor will be positioned on line "num" for the first
  112.         file being edited.  If "num" is missing, the cursor will be
  113.         positioned on the last line.
  114.  
  115.                             *-+/*
  116. +/{pat}        The cursor will be positioned on the first line containing
  117.         "pat" in the first file being edited (see |pattern| for the
  118.         available search patterns).
  119.  
  120. +{command}                        *-+c* *-c*
  121. -c {command}    "command" will be executed after the first file has been
  122.         read (and after autocommands and modelines for that file have
  123.         been processed).  "command" is interpreted as an Ex command.
  124.         If the "command" contains spaces, it must be enclosed in
  125.         double quotes (this depends on the shell that is used).
  126.         Example:
  127. >            vim  "+set si"  main.c
  128. >            vim  -c "set ff=dos"  -c wq  mine.mak
  129.  
  130.         Note: You can use up to 10 "+" or "-c" arguments in a Vim
  131.         command.  They are executed in the order given. {Vi only
  132.         allows one command}
  133.  
  134.                             *-r*
  135. -r        Recovery mode.  Without a file name argument, a list of
  136.         existing swap files is given.  With a file name, a swap file
  137.         is read to recover a crashed editing session.  See
  138.         |crash-recovery|.
  139.  
  140.                             *-L*
  141. -L        Same as -r.  {only in some versions of Vi: "List recoverable
  142.         edit sessions"}
  143.  
  144.                             *-R*
  145. -R        Readonly mode.  The 'readonly' option will be set for all the
  146.         files being edited.  You can still edit the buffer, but will
  147.         be prevented from accidentally overwriting a file.  If you
  148.         forgot that you are in View mode and did make some changes,
  149.         you can overwrite a file by adding an exclamation mark to
  150.         the Ex command, as in ":w!".  The 'readonly' option can be
  151.         reset with ":set noro" (see the options chapter, |options|).
  152.         Subsequent edits will not be done in readonly mode.  Calling
  153.         the executable "view" has the same effect as the -R argument.
  154.         The 'updatecount' option will be set to 10000, meaning that
  155.         the swap file will not be updated automatically very often.
  156.  
  157.                             *-Z*
  158. -Z        Restricted mode.  All commands that make use of an external
  159.         shell are disabled.  This includes suspending with CTRL-Z,
  160.         ":sh", filtering, etc..
  161.  
  162.                             *-v*
  163. -v        Start Ex in Vi mode.  Only makes a difference when the
  164.         executable is called "ex".
  165.  
  166.                             *-e*
  167. -e        Start Vim in Ex mode.  Only makes a difference when the
  168.         executable is not called "ex".
  169.  
  170.                             *-s-ex*
  171. -s        Silent or batch mode.  Only when Vim was started as "ex" or
  172.         when preceded with the "-e" argument.  Otherwise see |-s|.
  173.         To be used when Vim is used to execute Ex commands from a file
  174.         instead of a terminal.  Switches off most prompts and
  175.         informative messages.  But not warning and error messages, and
  176.         the output from commands that print text lines, like ":print"
  177.         and ":list".
  178.         Initializations are skipped (exept the ones given with the
  179.         "-u" argument).
  180.  
  181.                             *-b*
  182. -b        Binary mode.  File I/O will only recognize <NL> to separate
  183.         lines. The 'expandtab' option will be reset.  The 'textwidth'
  184.         option is set to 0.  'modeline' is reset.  The 'binary' option
  185.         is set.  This is done after reading the vimrc/exrc files but
  186.         before reading any file in the arglist.  See also
  187.         |edit-binary|.  {not in Vi}
  188.  
  189.                             *-l*
  190. -l        Lisp mode.  Sets the 'lisp' and 'showmatch' options on.
  191.  
  192.                             *-F*
  193. -F        Farsi mode.  Sets the 'fkmap' and 'rightleft' options on.
  194.         (Only when compiled with |+rightleft| and |+farsi| features,
  195.         otherwise Vim gives an error message and exits).  {not in Vi}
  196.  
  197.                             *-H*
  198. -H        Hebrew mode.  Sets the 'hkmap' and 'rightleft' options on.
  199.         (Only when compiled with the |+rightleft| feature, otherwise
  200.         Vim gives an error message and exits).  {not in Vi}
  201.  
  202.                             *-V* *verbose*
  203. -V[n]        Verbose.  Sets the 'verbose' option to [n][ (default: 10).
  204.         Messages will be given for each file that is ":source"d and
  205.         for reading or writing a viminfo file.  Can be used to find
  206.         out what is happening upon startup and exit.  {not in Vi}
  207.  
  208.                             *-C*
  209. -C        Compatible mode.  Sets the 'compatible' option.  You can use
  210.         this to get 'compatible', even though there is a .vimrc file.
  211.         Also see |compatible-default|.  {not in Vi}
  212.  
  213.                             *-N*
  214. -N        Not compatible mode.  Resets the 'compatible' option.  You can
  215.         use this to get 'nocompatible', when there is no .vimrc file.
  216.         Also see |compatible-default|.  {not in Vi}
  217.  
  218.                             *-n*
  219. -n        No swap file will be used.  Recovery after a crash will be
  220.         impossible.  Handy if you want to view or edit a file on a
  221.         very slow medium (e.g., a floppy).
  222.         Can also be done with ":set updatecount=0".  You can switch it
  223.         on again by setting the 'updatecount' option to some value,
  224.         e.g., ":set uc=100".
  225.         'updatecount' is set to 0 AFTER executing commands from a
  226.         vimrc file, but before the GUI initializations.  Thus it
  227.         overrides a setting for 'updatecount' in a vimrc file, but not
  228.         in a gvimrc file.  See |startup|.  {not in Vi}
  229.         When you want to reduce accesses to the disk (e.g., for a
  230.         laptop), don't use "-n", but set 'updatetime' and
  231.         'udpatecount' to very big numbers, and type ":preserve" when
  232.         you want to save your work.  This way you keep the possibility
  233.         for crash recovery.
  234.  
  235.                             *-o*
  236. -o[N]        Open N windows.  If [N] is not given, one window is opened
  237.         for every file given as argument.  If there is not enough
  238.         room, only the first few files get a window.  If there are
  239.         more windows than arguments, the last few windows will be
  240.         editing an empty file.  {not in Vi}
  241.  
  242.                             *-T*
  243. -T {terminal}    Set the terminal type to "terminal".  This influences the
  244.         codes that Vim will send to your terminal.  This is normally
  245.         not needed, because Vim will be able to find out what type
  246.         of terminal you are using (See |terminal-info|).  {not in Vi}
  247.  
  248.                             *-d*
  249. -d {device}    Amiga only: The "device" is opened to be used for editing.
  250.         Normally you would use this to set the window position and
  251.         size: "-d con:x/y/width/height", e.g.,
  252.         "-d con:30/10/600/150".  But you can also use it to start
  253.         editing on another device, e.g., AUX:.  {not in Vi}
  254.  
  255.                             *-f*
  256. -f        Amiga only: Do not restart Vim to open a new window.  This
  257.         option should be used when Vim is started by a program that
  258.         will wait for the edit session to finish (e.g., mail or
  259.         readnews).  See |amiga-window|.  {not in Vi}
  260.  
  261.         GUI only: Do not disconnect from the program that started Vim.
  262.         'f' stands for "foreground".  If omitted, the GUI forks a new
  263.         process and exits the current one.  "-f" should be used when
  264.         gvim is started by a program that will wait for the edit
  265.         session to finish (e.g., mail or readnews).  If you want gvim
  266.         never to fork, include 'f' in 'guioptions' in your .gvimrc.
  267.         Careful: You can use "-gf" to start the GUI in the foreground,
  268.         but "-fg" is used to specify the foreground color.  {not in
  269.         Vi} |gui-fork|
  270.  
  271.                             *-u*
  272. -u {vimrc}    The file "vimrc" is read for initializations.  Other
  273.         initializations are skipped; see |initialization|.  This can
  274.         be used to start Vim in a special mode, with special
  275.         mappings and settings.  A shell alias can be used to make
  276.         this easy to use.  For example:
  277. >            alias vimc vim -u ~/.c_vimrc !*
  278.         Also consider using autocommands; see |autocommand|.
  279.         When {vimrc} is equal to "NONE" (all uppercase), all
  280.         initializations from files and environment variables are
  281.         skipped, including reading the .gvimrc file when the GUI
  282.         starts.
  283.         Using the "-u" argument also means that the 'compatible'
  284.         option will be on by default.  This can have unexepected side
  285.         effects.  See |'compatible'|.
  286.         {not in Vi}
  287.  
  288.                             *-U*
  289. -U {gvimrc}    The file "gvimrc" is read for initializations when the GUI
  290.         starts.  Other GUI initializations are skipped. When {gvimrc}
  291.         is equal to "NONE", no file is read for initializations at
  292.         all.
  293.         Exception: Reading the system-wide menu file is always done.
  294.  
  295.                             *-i*
  296. -i {viminfo}    The file "viminfo" is used instead of the default viminfo
  297.         file.  If the name "NONE" is used (all uppercase), no viminfo
  298.         file is read or written, even if 'viminfo' is set or when
  299.         ":rv" or ":wv" are used.  See also |viminfo-file|.  {not in Vi}
  300.  
  301.                             *-x*
  302. -x        Use crypt to read/write files.  Not implemented yet.
  303.  
  304.                             *-s*
  305. -s {scriptin}    The script file "scriptin" is read.  The characters in the
  306.         file are interpreted as if you had typed them.  The same can
  307.         be done with the command ":source! {scriptin}".  If the end
  308.         of the file is reached before the editor exits, further
  309.         characters are read from the keyboard.  Only works when not
  310.         started in Ex mode, see |-s-ex|.  See also |complex-repeat|.
  311.         {not in Vi}
  312.  
  313.                             *-w*
  314. -w {scriptout}    All the characters that you type are recorded in the file
  315.         "scriptout", until you exit Vim.  This is useful if you want
  316.         to create a script file to be used with "vim -s" or
  317.         ":source!".  When the "scriptout" file already exists, new
  318.         characters are appended.  See also |complex-repeat|.  {not in
  319.         Vi}
  320.  
  321.                             *-W*
  322. -W {scriptout}    Like -w, but do not append, overwrite an existing file.  {not
  323.         in Vi}
  324.  
  325.                             *-w_nr*
  326. -w{number}    Does nothing.  This was included for Vi-compatibility.  In Vi
  327.         it sets the 'window' option, which is not implemented in Vim.
  328.  
  329. Example for using a script file to change a name in several files:
  330.     Create a file "subs.vi" containing substitute commands and a :wq
  331.     command:
  332. >        :%s/Jones/Smith/g
  333. >        :%s/Allen/Peter/g
  334. >        :wq
  335.  
  336.     Execute Vim on all files you want to change:
  337.  
  338. >        foreach i ( *.let ) vim -s subs.vi $i
  339.  
  340. If the executable is called "view", Vim will start in Readonly mode.  This is
  341. useful if you can make a hard or symbolic link from "view" to "vim".
  342. Starting in Readonly mode can also be done with "vim -R".
  343.  
  344. If the executable is called "ex", Vim will start in "Ex" mode.  This means it
  345. will accept only ":" commands.  But when the "-v" argument is given, Vim will
  346. start in in Normal mode anyway.
  347.  
  348. ==============================================================================
  349. 2. Vim on the Amiga                    *starting-amiga*
  350.  
  351. Starting Vim from the Workbench                *workbench*
  352. -------------------------------
  353.  
  354. Vim can be started from the Workbench by clicking on its icon twice.  It will
  355. then start with an empty buffer.
  356.  
  357. Vim can be started to edit one or more files by using a "Project" icon.  The
  358. "Default Tool" of the icon must be the full pathname of the Vim executable.
  359. The name of the ".info" file must be the same as the name of the text file.
  360. By clicking on this icon twice, Vim will be started with the file name as
  361. current file name, which will be read into the buffer (if it exists).  You can
  362. edit multiple files by pressing the shift key while clicking on icons, and
  363. clicking twice on the last one.  The "Default Tool" for all these icons must
  364. be the same.
  365.  
  366. It is not possible to give arguments to Vim, other than file names, from the
  367. workbench.
  368.  
  369. Vim window                        *amiga-window*
  370. ----------
  371.  
  372. Vim will run in the CLI window where it was started.  If Vim was started with
  373. the "run" or "runback" command, or if Vim was started from the workbench, it
  374. will open a window of its own.
  375.  
  376. Technical detail:
  377.     To open the new window a little trick is used.  As soon as Vim
  378.     recognizes that it does not run in a normal CLI window, it will
  379.     create a script file in "t:".  This script file contains the same
  380.     command as the one Vim was started with, and an "endcli" command.
  381.     This script file is then executed with a "newcli" command (the "c:run"
  382.     and "c:newcli" commands are required for this to work).  The script
  383.     file will hang around until reboot, or until you delete it.  This
  384.     method is required to get the ":sh" and ":!" commands to work
  385.     correctly.  But when Vim was started with the -f option (foreground
  386.     mode), this method is not used.  The reason for this is that
  387.     when a program starts Vim with the -f option it will wait for Vim to
  388.     exit.  With the script trick, the calling program does not know when
  389.     Vim exits.  The -f option can be used when Vim is started by a mail
  390.     program which also waits for the edit session to finish.  As a
  391.     consequence, the ":sh" and ":!" commands are not available when the
  392.     -f option is used.
  393.  
  394. Vim will automatically recognize the window size and react to window
  395. resizing.  Under Amiga DOS 1.3, it is advised to use the fastfonts program,
  396. "FF", to speed up display redrawing.
  397.  
  398. ==============================================================================
  399. 3. Initialization                *initialization* *startup*
  400.  
  401. This section is about the non-GUI version of Vim.  See |gui-fork| for
  402. additional initialization when starting the GUI.
  403.  
  404. At startup, Vim checks environment variables and files and sets values
  405. accordingly.  Vim proceeds in this order:
  406.  
  407. 1. Set the 'shell' option                *SHELL* *COMSPEC*
  408.     The environment variable SHELL, if it exists, is used to set the
  409.     'shell' option.  On MS-DOS and Win32, the COMPSPEC variable is used
  410.     if SHELL is not set.
  411.  
  412. 2. Set the 'term' option                *TERM*
  413.     The environment variable TERM, if it exists, is used to set the 'term'
  414.     option.
  415.  
  416. 3. Execute Ex commands, from environment variables and/or files
  417.     An environment variable is read as one Ex command line, where multiple
  418.     commands must be separated with '|' or "<NL>".
  419.                                 *vimrc* *exrc*
  420.     A file that contains initialization commands is called a "vimrc" file.
  421.     Each line in a vimrc file is executed as an Ex command line.  It is
  422.     sometimes also referred to as "exrc" file.  They are the same type of
  423.     file, but "exrc" is what Vi always used, "vimrc" is a Vim specific
  424.     name.  Also see |vimrc-intro|.
  425.  
  426.     If Vim was started with "-u filename", the file "filename" is used.
  427.     All following initializations until 4. are skipped.
  428.     "vim -u NONE" can be used to skip these initializations.  |-u|
  429.  
  430.     If Vim was started in Ex mode with the "-s" argument, all following
  431.     initializations until 4. are skipped.  Only the "-u" option is
  432.     interpreted.
  433.  
  434.      a. For Unix the system vimrc file is read for initializations.  The path
  435.     of this file is shown with the ":version" command.  Note that this
  436.     file is ALWAYS read in 'compatible' mode, since the automatic
  437.     resetting of 'compatible' is only done later.  Add a ":set nocp"
  438.     command if you like.
  439.  
  440.               *VIMINIT* *.vimrc* *_vimrc* *EXINIT* *.exrc* *_exrc*
  441.      b. Four places are searched for initializations.  The first that exists
  442.     is used, the others are ignored.
  443.     -  The environment variable VIMINIT (see also |compatible-default|) (*)
  444.     -  The user vimrc file(s):
  445.             "$HOME/.vimrc" (for Unix and OS/2) (*)
  446.             "$HOME/_vimrc" (for MS-DOS and Win32) (*)
  447.             "s:.vimrc"     (for Amiga) (*)
  448.             "$VIM\_vimrc"  (for MS-DOS and Win32) (*)
  449.         Note: For Unix, OS/2 and Amiga, when ".vimrc" does not exist,
  450.         "_vimrc" is also tried, in case an MS-DOS compatible file
  451.         system is used.  For MS-DOS and Win32 ".vimrc" is checked
  452.         after "_vimrc", in case long file names are used.
  453.         Note: For MS-DOS and Win32, "$HOME" is checked first.  If no
  454.         "_vimrc" or ".vimrc" is found there, "$VIM" is tried.
  455.         See |$VIM| for when $VIM is not set.
  456.     -  The environment variable EXINIT
  457.     -  The user exrc file(s).  Same as for the user vimrc file, but with
  458.        "vimrc" replaced by "exrc".  But without the (*)!
  459.  
  460.      c. If the 'exrc' option is on (which is not the default), the current
  461.     directory is searched for four files.  The first that exists is used,
  462.     the others are ignored.
  463.     -  The file ".vimrc" (for Unix, Amiga and OS/2) (*)
  464.             "_vimrc" (for MS-DOS and Win32) (*)
  465.     -  The file "_vimrc" (for Unix, Amiga and OS/2) (*)
  466.             ".vimrc" (for MS-DOS and Win32) (*)
  467.     -  The file ".exrc"  (for Unix, Amiga and OS/2)
  468.             "_exrc"  (for MS-DOS and Win32)
  469.     -  The file "_exrc"  (for Unix, Amiga and OS/2)
  470.             ".exrc"  (for MS-DOS and Win32)
  471.  
  472.      (*) Using this file or environment variable will cause 'compatible' to be
  473.      off by default.  See |compatible-default|.
  474.  
  475. 4. Set 'shellpipe' and 'shellredir'
  476.     The 'shellpipe' and 'shellredir' options are set according to the
  477.     value of the 'shell' option, unless they have been set before.
  478.     This means that Vim will figure out the values of 'shellpipe' and
  479.     'shellredir' for you, unless you have set them yourself.
  480.  
  481. 5. Set 'updatecount' to zero, if "-n" command argument used
  482.  
  483. 6. Set binary options
  484.     If the "-b" flag was given to Vim, the options for binary editing will
  485.     be set now.  See |-b|.
  486.  
  487. 7. Perform GUI initializations
  488.     Only when starting "gvim", the GUI initializations will be done.  See
  489.     |gui-init|.
  490.  
  491. 8. Read the viminfo file
  492.     If the 'viminfo' option is not empty, the viminfo file is read.  The
  493.     default is empty, so 'viminfo' must have been set by one of the
  494.     previous initializations.  See |viminfo-file|.
  495.  
  496. 9. Read the quickfix file
  497.     If the "-q" flag was given to Vim, the quickfix file is read.  If this
  498.     fails, Vim exits.
  499.  
  500. 10. Open all windows
  501.     When the |-o| flag was given, windows will be opened (but not
  502.     displayed yet).
  503.     When switching screens, it happens now.  Redrawing starts.
  504.     If the "-q" flag was given to Vim, the first error is jumped to.
  505.     Buffers for all windows will be loaded.
  506.  
  507. 11. Execute startup commands
  508.     If a "-t" flag was given to Vim, the tag is jumped to.
  509.     The commands given with the |-c| and |+cmd| arguments are executed.
  510.     If the 'insertmode' option is set, Insert mode is entered.
  511.     The |VimEnter| autocommands are executed.
  512.  
  513. Some hints on using initializations:
  514.  
  515. Standard setup:
  516. Create a vimrc file to set the default settings and mappings for all your edit
  517. sessions.  Put it in a place so that it will be found by 3b:
  518.     ~/.vimrc    (Unix and OS/2)
  519.     s:.vimrc    (Amiga)
  520.     $VIM\_vimrc    (MS-DOS and Win32)
  521. Note that creating a vimrc file will cause the 'compatible' option to be off
  522. by default.  See |compatible-default|.
  523.  
  524. Local setup:
  525. Put all commands that you need for editing a specific directory only into a
  526. vimrc file and place it in that directory under the name ".vimrc" ("_vimrc"
  527. for MS-DOS and Win32).  NOTE: To make Vim look for these special files you
  528. have to turn on the option 'exrc'.  See |trojan-horse| too.
  529.  
  530. System setup:
  531. This only applies if you are managing a Unix system with several users and
  532. want to set the defaults for all users.  Create a vimrc file with commands
  533. for default settings and mappings and put it in the place that is given with
  534. the ":version" command.
  535.  
  536. Saving the current state of Vim to a file:
  537. Whenever you have changed values of options or when you have created a
  538. mapping, then you may want to save them in a vimrc file for later use.  See
  539. |save-settings| about saving the current state of settings to a file.
  540.  
  541. Avoiding setup problems for Vi users:
  542. Vi uses the variable EXINIT and the file "~/.exrc".  So if you do not want to
  543. interfere with Vi, then use the variable VIMINIT and the file "vimrc" instead.
  544.  
  545. Amiga environment variables:
  546. On the Amiga, two types of environment variables exist.  The ones set with the
  547. DOS 1.3 (or later) setenv command are recognized.  See the AmigaDos 1.3
  548. manual.  The environment variables set with the old Manx Set command (before
  549. version 5.0) are not recognized.
  550.  
  551. MS-DOS line separators:
  552. On MS-DOS-like systems (MS-DOS itself, Win32, and OS/2), Vim assumes that all
  553. the vimrc files have <CR> <NL> pairs as line separators.  This will give
  554. problems if you have a file with only <NL>s and have a line like
  555. ":map xx yy^M".  The trailing ^M will be ignored.
  556.  
  557.                              *compatible-default*
  558. When Vim starts, the 'compatible' option is on.  This will be used when Vim
  559. starts its initializations.  But as soon as a user vimrc file is found, or a
  560. vimrc file in the current directory, or the "VIMINIT" environment variable is
  561. set, it will be set to 'nocompatible'.  This has the side effect of setting or
  562. resetting other options (see 'compatible').  But only the options that have
  563. not been set or reset will be changed.  This has the same effect like the
  564. value of 'compatible' had this value when starting Vim.
  565.  
  566. But there is a side effect of setting or resetting 'compatible' at the moment
  567. a .vimrc file is found: Mappings are interpreted the moment they are
  568. encountered.  This makes a difference when using things like "<CR>".  If the
  569. mappings depend on a certain value of 'compatible', set or reset it before
  570. giving the mapping.
  571.  
  572. The above behaviour can be overridden in these ways:
  573. - If the "-N" command line argument is given, 'nocompatible' will be used,
  574.   even when no vimrc file exists.
  575. - If the "-C" command line argument is given, 'compatible' will be used, even
  576.   when a vimrc file exists.
  577. - If the "-u {vimrc}" argument is used, 'compatible' will be used.
  578. - When the name of the executable ends in "ex", then this works like the "-C"
  579.   argument was given: 'compatible' will be used, even when a vimrc file
  580.   exists.  This has been done to make Vim behave like "ex", when it is started
  581.   as "ex".
  582.  
  583. Avoiding trojan horses:                    *trojan-horse*
  584. While reading the "vimrc" or the "exrc" file in the current directory, some
  585. commands can be disabled for security reasons by setting the 'secure' option.
  586. This is always done when executing the command from a tags file.  Otherwise it
  587. would be possible that you accidentally use a vimrc or tags file that somebody
  588. else created and contains nasty commands.  The disabled commands are the ones
  589. that start a shell, the ones that write to a file, and ":autocmd".  The ":map"
  590. commands are echoed, so you can see which keys are being mapped.
  591.     If you want Vim to execute all commands in a local vimrc file, you
  592. can reset the 'secure' option in the EXINIT or VIMINIT environment variable or
  593. in the global "exrc" or "vimrc" file.  This is not possible in "vimrc" or
  594. "exrc" in the current directory, for obvious reasons.
  595.     On Unix systems, this only happens if you are not the owner of the
  596. vimrc file.  Warning: If you unpack an archive that contains a vimrc or exrc
  597. file, it will be owned by you.  You won't have the security protection.  Check
  598. the vimrc file before you start Vim in that directory, or reset the 'exrc'
  599. option.  Some Unix systems allow a user to do "chown" on a file.  This makes
  600. it possible for another user to create a nasty vimrc and make you the owner.
  601. Be careful!
  602.     When using tag search commands, executing the search command (the last
  603. part of the line in the tags file) is always done in secure mode.  This works
  604. just like executing a command from a vimrc/exrc in the current directory.
  605.  
  606.                             *slow-start*
  607. If Vim takes a long time to start up, there may be a few causes:
  608. - If the Unix version was compiled with the GUI and/or X11 (check the output
  609.   of ":version" for "+GUI" and "+X11"), it may need to load shared libraries
  610.   and connect to the X11 server.  Try compiling a version with GUI and X11
  611.   disabled.  This also should make the executable smaller.
  612. - If you have "viminfo" enabled, the loading of the viminfo file may take a
  613.   while.  You can find out if this is the problem by disabling viminfo for a
  614.   moment (use the Vim argument "-i NONE", |-i|).  Try reducing the number of
  615.   lines stored in a register with ":set viminfo='20\"50".
  616.                             |viminfo-file|.
  617.  
  618.                             *:intro*
  619. When Vim starts without a file name, an introductory message is displayed (for
  620. those who don't know what Vim is).  It is removed as soon as the display is
  621. redrawn in any way.  To see the message again, use the ":intro" command.
  622. To avoid the intro message on startup, add the 'I' flag to 'shortmess'.
  623.  
  624. ==============================================================================
  625. 4. Suspending                        *suspend*
  626.  
  627.                         *iconise* *CTRL-Z* *v_CTRL-Z*
  628. CTRL-Z            Suspend Vim.
  629.             Works in Normal and in Visual mode.  In Insert and
  630.             Command-line mode, the CTRL-Z is inserted as a normal
  631.             character.
  632.  
  633.  
  634. :sus[pend][!]    or            *:sus* *:suspend* *:st* *:stop*
  635. :st[op][!]        Suspend Vim, like with CTRL-Z.  If the '!' is
  636.             not given, the buffer was changed, 'autowrite' is set,
  637.             and a file name is known, the buffer will be written.
  638.  
  639. In the GUI, suspending is implemented as iconising gvim.  In Windows 95/NT,
  640. gvim is minimised.
  641.  
  642. On many Unix systems, it is possible to suspend Vim with CTRL-Z.  This is only
  643. possible in Normal and Visual mode (see next chapter, |vim-modes|).  Vim will
  644. continue if you make it the foreground job again.  On other systems, CTRL-Z
  645. will start a new shell.  This is the same as the ":sh" command.  Vim will
  646. continue if you exit from the shell.
  647.  
  648. ==============================================================================
  649. 5. The vimrc file                    *vimrc-intro*
  650.  
  651. A vimrc file can be used for settings you intend to use more-or-less for every
  652. of your Vim sessions.  Normally the file is called $HOME/.vimrc, but other
  653. files can also be used, see |vimrc|.  Vim will read it (them) when starting
  654. and interpret the commands in them.
  655.  
  656. The vimrc file can contain anything that can be typed on the Vim command line.
  657. The recommended practice is not to include the preceding colon sign ":", thus
  658. if one would type
  659. >    :set number
  660. on the Vim command line, the same can appear in the vimrc file simply as
  661. >    set number
  662.  
  663. The end-of-line character depends on the system.  For Unix a single <NL>
  664. character is used.  For MS-DOS, Windows, OS/2 and the like, <CR><LF> is used.
  665. This is important when using mappings that end in a <CR>.  See |:source_crnl|.
  666.  
  667. Blank lines are allowed and ignored.
  668.  
  669. Leading whitespace characters (blanks and TABs) are always ignored.  The
  670. whitespaces between parameters (e.g. between the 'set' and the 'number' in the
  671. example above) are reduced to one blank character and plays the role of a
  672. separator, the whitespaces after the last (visible) character may or may not
  673. be ignored depending on the situation, see below.
  674.  
  675. For a ":set" command involving the "=" (equal) sign, such as in
  676. >    set cpoptions    =aABceFst
  677. the whitespace immediately before the "=" sign is ignored.  But there can be
  678. no whitespace after the "=" sign!
  679.  
  680. To include a whitespace character in the value of an option, it must be
  681. escaped by a "\" (backslash)  as in the following example:
  682. >    set tags=my\ nice\ file
  683. The same example written as
  684. >    set tags=my nice file
  685. will issue an error, because it is interpreted as:
  686. >    set tags=my
  687. >    set nice
  688. >    set file
  689.  
  690. The character " (the double quote mark) starts a comment.  Everything after
  691. and including this character until the end-of-line is considered a comment and
  692. is ignored, except for commands that don't consider comments, as shown in
  693. examples below.  A comment can start on any character position on the line.
  694.  
  695. There is a little "catch" with comments:
  696. >    ab dev development        " shorthand
  697. >    map <F3> o#include        " insert include
  698. >    !ls *.c                " list C files
  699. The abbreviation 'dev' will be expand to 'development     " shorthand'.  The
  700. mapping of <F3> will actually be the whole line after the 'o# ....' including
  701. the '" insert include'.  The "!" command will send everything after it to the
  702. shell, causing an error for an unmatched '"' character.
  703. There can be no comments after ":map", ":ab" and "!" commands.
  704.  
  705. For these commands, any character until the end-of-line is included.  As a
  706. consequence of this behaviour, you don't always see that trailing whitespace
  707. is included:
  708. >    map <F4> o#include
  709. To avoid these problems, you can set the 'list' option when editing vimrc
  710. files.
  711.  
  712. Even bigger problem arises in the following example:
  713. >    map ,ab o#include
  714. >    unmap ,ab
  715. Here the mapping of ,ab will be ',ab', no trailing whitespaces is included.
  716. However, the "unmap" does not end directly with the end-of-line, Vim will try
  717. to unmap ',ab ', which does not exist as a mapped sequence.  An error will be
  718. issued, which is very hard to identify, because the ending whitespace
  719. character on the 'unmap ,ab ' are not visible.
  720.  
  721. And this is exactly the same what happens when one uses a comment after an
  722. 'unmap' command:
  723. >    unmap ,ab     " comment
  724. Here the comment part will be ignored.  However, Vim will try to unmap
  725. ',ab     ', which does not exist,  Deleting the comment as well as all the
  726. whitespaces up the ending 'b' character will cure the problem.
  727.  
  728. Except for the situations as above, it is legal to put a comment on the same
  729. line as the Vim definitions, such as
  730. >    set number    " display line numbers
  731.  
  732. ==============================================================================
  733. 6. The viminfo file                    *viminfo-file*
  734.  
  735. The viminfo file is used to store:
  736. - The command line history.
  737. - The search string history.
  738. - Contents of registers.
  739. - Marks for several files.
  740. - File marks, pointing to locations in files.
  741. - Last search/substitute pattern (for 'n' and '&').
  742.  
  743. The viminfo file is not supported when the |+viminfo| feature has been
  744. disabled at compile time.
  745.  
  746.                             *viminfo-read*
  747. When Vim is started and the 'viminfo' option is non-empty, the contents of
  748. the viminfo file are read and the info can be used in the appropriate places.
  749. The marks are not read in at startup (but file marks are).  See
  750. |initialization| for how to set the 'viminfo' option upon startup.
  751.  
  752.                             *viminfo-write*
  753. When Vim exits and 'viminfo' is non-empty, the info is stored in the viminfo
  754. file (it's actually merged with the existing one, if one exists).  The
  755. 'viminfo' option is a string containing information about what info should be
  756. stored, and contains limits on how much should be stored (see 'viminfo').
  757.  
  758. Notes for Unix:
  759. - The file protection for the viminfo file will be set to prevent other users
  760.   from being able to read it, because it may contain any text or commands that
  761.   you have worked with.
  762. - If you want to share the viminfo file with other users (e.g. when you "su"
  763.   to another user), you can make the file writable for the group or everybody.
  764.   Vim will preserve this when writing new viminfo files.  Be careful, don't
  765.   allow just anybody to read and write your viminfo file!
  766. - Vim will not overwrite a viminfo file that is not writable by the current
  767.   "real" user.  This helps for when you did "su" to become root, but your
  768.   $HOME is still set to a normal user's home directory.  Otherwise Vim would
  769.   create a viminfo file owned by root that nobody else can read.
  770.  
  771. Marks are stored for each file separately.  When a file is read and 'viminfo'
  772. is non-empty, the marks for that file are read from the viminfo file.  NOTE:
  773. The marks are only written when exiting Vim, which is fine because marks are
  774. remembered for all the files you have opened in the current editing session,
  775. unless ":bdel" is used.  If you want to save the marks for a file that you are
  776. about to abandon with ":bdel", use ":wv".  The '[' and ']' marks are not
  777. stored, but the '"' mark is.  The '"' mark is very useful for jumping to the
  778. cursor position when the file was last exited.  No marks are saved for files
  779. that start with any string given with the "r" flag in 'viminfo'.  This can be
  780. used to avoid saving marks for files on removable media (for MS-DOS you would
  781. use "ra:,rb:", for Amiga "rdf0:,rdf1:,rdf2:").
  782.  
  783.                             *viminfo-file-marks*
  784. Uppercase marks ('A to 'Z) are stored when writing the viminfo file.  The
  785. numbered marks ('0 to '9) are a bit special.  When the viminfo file is written
  786. (when exiting or with the ":wviminfo" command), '0 is set to the current cursor
  787. position and file.  The old '0 is moved to '1, '1 to '2, etc.  This
  788. resembles what happens with the "1 to "9 delete registers.  If the current
  789. cursor position is already present in '0 to '9, it is moved to '0, to avoid
  790. having the same position twice.  The result is that with "'0", you can jump
  791. back to the file and line where you exited Vim.  To do that right away, try
  792. using this command, which makes an alias for it):
  793.  
  794.     alias lvim vim -c '"'normal "'"0'"'
  795.  
  796. Viminfo file name:                    *viminfo-file-name*
  797. - The default name of the viminfo file is "$HOME/.viminfo" for Unix,
  798.   "s:.viminfo" for Amiga, "$HOME\_viminfo" for MS-DOS and Win32.  For the last
  799.   two, when $HOME is not set, "$VIM\_viminfo" is used.  When $VIM is also not
  800.   set, "c:\_viminfo" is used.
  801. - The 'n' flag in the 'viminfo' option can be used to specify another viminfo
  802.   file name |'viminfo'|.
  803. - The "-i" Vim argument can be used to set another file name, |-i|.  When the
  804.   file name given is "NONE" (all uppercase), no viminfo file is ever read or
  805.   written.  Also not for the commands below!
  806. - For the commands below, another file name can be given, overriding the
  807.   default and the name given with 'viminfo' or "-i" (unless it's NONE).
  808.  
  809. Two commands can be used to read and write the viminfo file manually.  This
  810. can be used to exchange registers between two running Vim programs: First
  811. type ":wv" in one and then ":rv" in the other.  Note that if the register
  812. already contained something, then ":rv!" would be required.  Also note
  813. however that this means everything will be overwritten with information from
  814. the first Vim, including the command line history, etc.
  815.  
  816. The viminfo file itself can be edited by hand too, although we suggest you
  817. start with an existing one to get the format right.  It is reasonably
  818. self-explanatory once you're in there.  This can be useful in order to
  819. create a second file, say "~/.my_viminfo" which could contain certain
  820. settings that you always want when you first start Vim.  For example, you
  821. can preload registers with particular data, or put certain commands in the
  822. command line history.  A line in your .vimrc file like
  823. >    rviminfo! ~/.my_viminfo
  824. can be used to load this information.  You could even have different viminfos
  825. for different types of files (e.g., C code) and load them based on the file
  826. name, using the ":autocmd" command (see |:autocmd|).
  827.  
  828.                             *viminfo-errors*
  829. When Vim detects an error while reading a viminfo file, it will not overwrite
  830. that file.  If there are more than 10 errors, Vim stops reading the viminfo
  831. file.  This was done to avoid accidently destroying a file when the file name
  832. of the viminfo file is wrong.  This could happen when accidently typing "vim
  833. -i file" when you wanted "vim -R file" (yes, somebody accidently did that!).
  834. If you want to overwrite a viminfo file with an error in it, you will either
  835. have to fix the error, or delete the file (while Vim is running, so most of
  836. the information will be restored).
  837.  
  838.                            *:rv* *:rviminfo*
  839. :rv[iminfo][!] [file]    Read from viminfo file [file] (default: see above).
  840.             If [!] is given, then any information that is
  841.             already set (registers, marks, etc.) will be
  842.             overwritten.  {not in Vi}
  843.  
  844.                            *:wv* *:wviminfo*
  845. :wv[iminfo][!] [file]    Write to viminfo file [file] (default: see above).
  846.             The information in the file is first read in to make
  847.             a merge between old and new info.  When [!] is used,
  848.             the old information is not read first, only the
  849.             internal info is written.  If 'viminfo' is empty, marks
  850.             for up to 100 files will be written.  {not in Vi}
  851.  
  852.  vim:tw=78:ts=8:sw=8:
  853.