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

  1. *eval.txt*      For Vim version 5.3.  Last modification: 1998 Aug 22
  2.  
  3.  
  4.           VIM REFERENCE MANUAL    by Bram Moolenaar
  5.  
  6.  
  7. Expression evaluation                    *expression* *expr*
  8.  
  9. Note: Expression evaluation can be disabled at compile time.  If this has been
  10. done, the features in this document are not available.  See |+eval|.
  11.  
  12. 1. Variables        |variables|
  13. 2. Expression syntax    |expression-syntax|
  14. 3. Internal variable    |internal-variables|
  15. 4. Builtin Functions    |functions|
  16. 5. Defining functions    |user-functions|
  17. 6. Commands        |expression-commands|
  18.  
  19. {Vi does not have any of these commands}
  20.  
  21. ==============================================================================
  22. 1. Variables                        *variables*
  23.  
  24. There are two types of variables:
  25.  
  26. Number        a 32 bit signed number
  27. String        a NUL terminated string of 8-bit unsigned characters.
  28.  
  29. These are converted automatically, depending on how they are used.
  30.  
  31. Conversion from a Number to a String is by making the ASCII representation of
  32. the Number.  Examples:
  33. >    Number 123    -->    String "123"
  34. >    Number 0    -->    String "0"
  35. >    Number -1    -->    String "-1"
  36.  
  37. Conversion from a String to a Number is done by converting the first digits
  38. to a number.  Hexadecimal "0xf9" and Octal "017" numbers are recognized.  If
  39. the String doesn't start with digits, the result is zero.  Examples:
  40. >    String "456"    -->    Number 456
  41. >    String "6bar"    -->    Number 6
  42. >    String "foo"    -->    Number 0
  43. >    String "0xf1"    -->    Number 241
  44. >    String "0100"    -->    Number 64
  45.  
  46. For boolean operators Numbers are used.  Zero is FALSE, non-zero is TRUE.
  47.  
  48. Note that in the command
  49.     :if "foo"
  50. "foo" is converted to 0, which means FALSE.  To test for a non-empty string,
  51. use strlen():
  52.     :if strlen("foo")
  53.  
  54. ==============================================================================
  55. 2. Expression syntax                    *expression-syntax*
  56.  
  57. Expression syntax summary, from least to most significant:
  58.  
  59. |expr1|    expr2 || expr2 ..    logical OR
  60.  
  61. |expr2|    expr3 && expr3 ..    logical AND
  62.  
  63. |expr3|    expr4 == expr4        equal
  64.     expr4 != expr4        not equal
  65.     expr4 >     expr4        greater than
  66.     expr4 >= expr4        greater than or equal
  67.     expr4 <     expr4        smaller than
  68.     expr4 <= expr4        smaller than or equal
  69.     expr4 =~ expr4        regexp matches
  70.     expr4 !~ expr4        regexp doesn't match
  71.  
  72. |expr4|    expr5 +     expr5 ..    number addition
  73.     expr5 -     expr5 ..    number subtraction
  74.     expr5 .     expr5 ..    string concatenation
  75.  
  76. |expr5|    expr6 *     expr6 ..    number multiplication
  77.     expr6 /     expr6 ..    number division
  78.     expr6 %     expr6 ..    number modulo
  79.  
  80. |expr6|    ! expr6            logical NOT
  81.     - expr6            unary minus
  82.  
  83. |expr7|    expr8[expr1]        index in String
  84.  
  85. |expr8|    number            number constant
  86.     "string"        string constant
  87.     'string'        literal string constant
  88.     &option            option value
  89.     (expr1)            nested expression
  90.     variable        internal variable
  91.     $VAR            environment variable
  92.     @r            contents of register 'r'
  93.     function(expr1, ...)    function call
  94.  
  95. ".." indicates that the operations in this level can be concatenated.
  96. Example:
  97. >    &nu || &list && &shell == "csh"
  98.  
  99. All expressions within one level are parsed from left to right.
  100.  
  101.  
  102. expr1 and expr2                        *expr1* *expr2*
  103. ---------------
  104.  
  105.                         *expr-barbar* *expr-&&*
  106. The "||" and "&&" operators take one argument on each side.  The arguments
  107. are (converted to) Numbers.  The result is:
  108.  
  109.      input                 output            ~
  110.     n1        n2        n1 || n2    n1 && n2    ~
  111.     zero    zero        zero        zero
  112.     zero    non-zero    non-zero    zero
  113.     non-zero    zero        non-zero    zero
  114.     non-zero    non-zero    non-zero    non-zero
  115.  
  116. The operators can be concatenated, for example:
  117.  
  118. >    &nu || &list && &shell == "csh"
  119.  
  120. Note that "&&" takes precedence over "||", so this has the meaning of:
  121.  
  122. >    &nu || (&list && &shell == "csh")
  123.  
  124. All arguments are computed, there is no skipping if the value of an argument
  125. doesn't matter, because the result is already known.  This is different from
  126. C, although it only matters for errors (unknown variables), since there are no
  127. side effects from an expression.
  128.  
  129.  
  130. expr3                            *expr3*
  131. -----
  132.     expr4 == expr4        equal            *expr-==*
  133.     expr4 != expr4        not equal        *expr-!=*
  134.     expr4 >     expr4        greater than        *expr->*
  135.     expr4 >= expr4        greater than or equal    *expr->=*
  136.     expr4 <     expr4        smaller than        *expr-<*
  137.     expr4 <= expr4        smaller than or equal    *expr-<=*
  138.     expr4 =~ expr4        regexp matches        *expr-=~*
  139.     expr4 !~ expr4        regexp doesn't match    *expr-!~*
  140.  
  141. When comparing a String with a Number, the String is converted to a Number,
  142. and the comparison is done on Numbers.
  143.  
  144. When comparing two Strings, this is done with strcmp().  This results in the
  145. mathematical difference, not necessarily the alphabetical difference in the
  146. local language.
  147.  
  148. The "=~" and "!~" operators match the lefthand argument with the righthand
  149. argument, which is used as a pattern.  See |pattern| for what a pattern is.
  150. This matching is always done like 'magic' was set, no matter what the actual
  151. value of 'magic' is.  This makes scripts portable.  The value of 'ignorecase'
  152. does matter though.  To avoid backslashes in the regexp pattern to be doubled,
  153. use a single-quote string, see |literal-string|.
  154.  
  155.  
  156. expr4 and expr5                        *expr4* *expr5*
  157. ---------------
  158.     expr5 +     expr5 ..    number addition        *expr-+*
  159.     expr5 -     expr5 ..    number subtraction    *expr--*
  160.     expr5 .     expr5 ..    string concatenation    *expr-.*
  161.  
  162.     expr6 *     expr6 ..    number multiplication    *expr-star*
  163.     expr6 /     expr6 ..    number division        *expr-/*
  164.     expr6 %     expr6 ..    number modulo        *expr-%*
  165.  
  166. For all, except ".", Strings are converted to Numbers.
  167.  
  168. Note the difference between "+" and ".":
  169.     "123" + "456" = 579
  170.     "123" . "456" = "123456"
  171.  
  172. When the righthand side of '/' is zero, the result is 0xfffffff.
  173. When the righthand side of '%' is zero, the result is 0.
  174.  
  175.  
  176. expr6                            *expr6*
  177. -----
  178.     ! expr6            logical NOT        *expr-!*
  179.     - expr6            unary minus        *expr-unary--*
  180.  
  181. For '!' non-zero becomes zero, zero becomes one.
  182. For '-' the sign of the number is changed.
  183.  
  184. A String will be converted to a Number first.
  185.  
  186. These two can be repeated and mixed.  Examples:
  187.     !-1        == 0
  188.     !!8        == 1
  189.     --9        == 9
  190.  
  191.  
  192. expr7                            *expr7*
  193. -----
  194.     expr8[expr1]        index in String        *expr-[]*
  195.  
  196. This results in a String that contains the expr1'th single character from
  197. expr8.  expr8 is used as a String, expr1 as a Number.
  198.  
  199. Note that index zero gives the first character.  This is like it works in C.
  200. Careful: column numbers start with one!  Example, to get the character under
  201. the cursor:
  202. >   c = getline(line("."))[col(".") - 1]
  203.  
  204. If the length of the String is less than the index, the result is an empty
  205. String.
  206.  
  207.                             *expr8*
  208. number
  209. ------
  210.     number            number constant        *expr-number*
  211.  
  212. Decimal, Hexadecimal (starting with 0x or 0X), or Octal (starting with 0).
  213.  
  214.  
  215. string                            *expr-string*
  216. ------
  217.     "string"        string constant        *expr-quote*
  218.  
  219. Note that double quotes are used.
  220.  
  221. A string constant accepts these special characters:
  222.     \...    three-digit octal number (e.g., "\316")
  223.     \..    two-digit octal number (must be followed by non-digit)
  224.     \.    one-digit octal number (must be followed by non-digit)
  225.     \x..    two-character hex number (e.g., "\x1f")
  226.     \x.    one-character hex number (must be followed by non-hex)
  227.     \X..    same as \x..
  228.     \X.    same as \x.
  229.     \b    backspace <BS>
  230.     \e    escape <Esc>
  231.     \f    formfeed <FF>
  232.     \n    newline <NL>
  233.     \r    return <CR>
  234.     \t    tab <Tab>
  235.     \\    backslash
  236.     \"    double quote
  237.     \<xxx>    Special key named "xxx".  e.g. "\<C-W>" for CTRL-W.
  238.  
  239. Note that "\000" and "\x00" force the end of the string.
  240.  
  241.  
  242. literal-string                        *literal-string*
  243. ---------------
  244.     'string'        literal string constant        *expr-'*
  245.  
  246. Note that single quotes are used.
  247.  
  248. This string is taken literally.  No backslashes are removed or have a special
  249. meaning.  A literal-string cannot contain a single quote.  Use a normal string
  250. for that.
  251.  
  252.  
  253. option                            *expr-option*
  254. ------
  255.     &option            option value
  256.  
  257. Any option name can be used here.  See |options|.
  258.  
  259.  
  260. register                        *expr-register*
  261. --------
  262.     @r            contents of register 'r'
  263.  
  264. The result is the contents of the named register, as a single string.
  265. Newlines are inserted where required.  To get the contents of the unnamed
  266. register use @@.  The '=' register can not be used here.  See |registers| for
  267. an explanation of the available registers.
  268.  
  269.  
  270. nesting                            *expr-nesting*
  271. -------
  272.     (expr1)            nested expression
  273.  
  274.  
  275. environment variable                    *expr-env*
  276. --------------------
  277.     $VAR            environment variable
  278.  
  279. The String value of any environment variable.  When it is not defined, the
  280. result is an empty string.
  281.  
  282.  
  283. internal variable                    *expr-variable*
  284. -----------------
  285.     variable        internal variable
  286. See below |internal-variables|.
  287.  
  288.  
  289. function call                        *expr-function*
  290. -------------
  291.     function(expr1, ...)    function call
  292. See below |functions|.
  293.  
  294.  
  295. ==============================================================================
  296. 3. Internal variable                    *internal-variables*
  297.  
  298. An internal variable name can be made up of letters, digits and '_'.  But it
  299. cannot start with a digit.
  300.  
  301. An internal variable is created with the ":let" command |:let|.
  302. An internal variable is destroyed with the ":unlet" command |:unlet|.
  303. Using a name that isn't an internal variable, or an internal variable that has
  304. been destroyed, results in an error.
  305.  
  306. A variable name that is preceded with "b:" is local to the current buffer.
  307. A variable name that is preceded with "w:" is local to the current window.
  308. Inside functions global variables are accessed with "g:".
  309.  
  310. Predefined variables:
  311.                             *count-variable*
  312. count        The count given for the last Normal mode command.  Can be used
  313.         to get the count before a mapping.  Example:
  314. >    :map _x :<C-U>echo "the count is " . count<CR>
  315.         Note: The <C-U> is required to remove the line range that you
  316.         get when typing ':' after a count.  read-only.
  317.  
  318.                             *errmsg-variable*
  319. errmsg        Last given error message.  It's allowed to set this variable.
  320.         Example:
  321. >    :let errmsg = ""
  322. >    :next
  323. >    :if (errmsg != "")
  324. >    :  ...
  325.  
  326.                             *shell_error-variable*
  327. shell_error    Result of the last shell command.  When non-zero, the last
  328.         shell command had an error.  When zero, there was no problem.
  329.         This only works when the shell returns the error code to Vim.
  330.         The value -1 is often used when the command could not be
  331.         executed.
  332.         Example:
  333. >    :!mv foo bar
  334. >    :if shell_error
  335. >    :  echo 'could not rename "foo" to "bar"!'
  336. >    :endif
  337.  
  338.                             *this_session-variable*
  339. this_session    Full filename of the last loaded or saved session file.  See
  340.         |:mksession|.
  341.  
  342.                             *version-variable*
  343. version        Version number of Vim: Major version number times 100 plus
  344.         minor version number.  Version 5.0 is 500.  Version 5.1 (5.01)
  345.         is 501.  Read-only.
  346.  
  347. ==============================================================================
  348. 4. Builtin Functions                    *functions*
  349.  
  350. USAGE                RESULT    DESCRIPTION    ~
  351.  
  352. argc()                Number  number of files in the argument list
  353. argv({nr})            String  {nr} entry of the argument list
  354. browse({save}, {title}, {initdir}, {default})
  355.                 String    put up a file requester
  356. bufexists({expr})        Number    TRUE if a buffer {exp} exists
  357. bufname({expr})            String    Name of the buffer {expr}
  358. bufnr({expr})            Number    Number of the buffer {expr}
  359. char2nr({expr})            Number  ASCII value of first char in {expr}
  360. col({expr})            Number    column nr of cursor or mark
  361. confirm({msg}, {choices}, {default})
  362.                 Number    number of choice picked by user
  363. delete({fname})            Number    delete file {fname}
  364. escape({string}, {chars})    String    escape {chars} in {string} with '\'
  365. exists({var})            Number    TRUE if {var} exists
  366. expand({expr})            String    expand file wildcards in {expr}
  367. filereadable({file})        Number    TRUE if {file} is a readable file
  368. fnamemodify({fname}, {mods})    String    modify file name
  369. getcwd()            String  the current working directory
  370. getline({lnum})            String    line {lnum} from current buffer
  371. has({feature})            Number    TRUE if feature {feature} supported
  372. hlexists({name})        Number    TRUE if highlight group {name} exists
  373. hlID({name})            Number  syntax ID of highlight group {name}
  374. hostname()            String    name of the machine vim is running on
  375. input({prompt})            String    get input from the user
  376. isdirectory({directory})    Number    TRUE if {directory} is a directory
  377. line({expr})            Number    line nr of cursor, last line or mark
  378. match({expr}, {pat})        Number    position where {pat} matches in {expr}
  379. matchend({expr}, {pat})        Number    position where {pat} ends in {expr}
  380. matchstr({expr}, {pat})        String    match of {pat} in {expr}
  381. nr2char({expr})            String    single char with ASCII value {expr}
  382. setline({lnum}, {line})        Number    Set line {lnum} to {line}
  383. strftime({expr})        String    current time in specified format
  384. strlen({expr})            Number    length of the String {expr}
  385. strpart({src}, {start}, {len})    String    {len} characters of {src} at {start}
  386. synID({line}, {col}, {trans})    Number  syntax ID at {line} and {col}
  387. synIDattr({synID}, {what})    String  attribute {what} of syntax ID {synID}
  388. synIDtrans({synID})        Number  translated syntax ID of {synID}
  389. substitute({expr}, {pat}, {sub}, {flags})
  390.                 String    all {pat} in {expr} replaced with {sub}
  391. tempname()            String    name for a temporary file
  392. virtcol({expr})            Number    screen column of cursor or mark
  393. winbufnr({nr})            Number    buffer number of window {nr}
  394. winheight({nr})            Number    height of window {nr}
  395. winnr()                Number    number of current window
  396.  
  397.                             *argc()*
  398. argc()        The result is the number of files in the argument list.  See
  399.         |arglist|.
  400.  
  401.                             *argv()*
  402. argv({nr})    The result is the {nr}th file in the argument list.  See
  403.         |arglist|.  "argv(0)" is the first one.  Example:
  404. >    let i = 0
  405. >    while i < argc()
  406. >      let f = substitute(argv(i), '\([. ]\)', '\\&', 'g')
  407. >      exe 'amenu Arg.' . f . ' :e ' . f . '<CR>'
  408. >      let i = i + 1
  409. >    endwhile
  410.  
  411.                             *browse()*
  412. browse({save}, {title}, {initdir}, {default})
  413.         Put up a file requester.  This only works when "has("browse")"
  414.         returns non-zero (only in some GUI versions).
  415.         The input fields are:
  416.             {save}    when non-zero, select file to write
  417.             {title}    title for the requester
  418.             {initdir}    directory to start browsing in
  419.             {default}    default file name
  420.         When the "Cancel" button is hit, something went wrong, or
  421.         browsing is not possible, an empty string is returned.
  422.  
  423.                             *bufexists()*
  424. bufexists({var})
  425.         The result is a Number, which is non-zero if a buffer called
  426.         {var} exists.  If the {var} argument is a string it must match
  427.         a buffer name exactly.  If the {var} argument is a number
  428.         buffer numbers are used.  Use "bufexists(0)" to test for the
  429.         existence of an alternate file name.
  430.                             *buffer_exists()*
  431.         Obsolete name: buffer_exists().
  432.  
  433.                             *bufname()*
  434. bufname({expr})
  435.         The result is the name of a buffer, as it is displayed by the
  436.         ":ls" command.
  437.         If {expr} is a Number, that buffer number's name is given.
  438.         Number zero is the alternate buffer for the current window.
  439.         If {expr} is a String, it is used as a regexp pattern to match
  440.         with the buffer names.  When there is more than one match an
  441.         empty string is returned.  "" or "%" can be used for the
  442.         current buffer, "#" for the alternate buffer.
  443.         If the {expr} is a String, but you want to use it as a buffer
  444.         number, force it to be a Number by adding zero to it:
  445. >            echo bufname("3" + 0)
  446.         If the buffer doesn't exist, or doesn't have a name, an empty
  447.         string is returned.
  448. >  bufname("#")            alternate buffer name
  449. >  bufname(3)            name of buffer 3
  450. >  bufname("%")            name of current buffer
  451. >  bufname("file2")        name of buffer where "file2" matches.
  452.                             *buffer_name()*
  453.         Obsolete name: buffer_name().
  454.  
  455.                             *bufnr()*
  456. bufnr({expr})    The result is the number of a buffer, as it is displayed by
  457.         the ":ls" command.  For the use of {expr}, see bufname()
  458.         above.  If the buffer doesn't exist, -1 is returned.
  459.         bufnr("$") is the last buffer:
  460. >  :let last_buffer = bufnr("$")
  461.         The result is a Number, which is the highest buffer number
  462.         of existing buffers.  Note that not all buffers with a smaller
  463.         number necessarily exist, because ":bdel" may have removed
  464.         them.  Use bufexists() to test for the existence of a buffer.
  465.                             *buffer_number()*
  466.         Obsolete name: buffer_number().
  467.                             *last_buffer_nr()*
  468.         Obsolete name for bufnr("$"): last_buffer_nr().
  469.  
  470.                             *char2nr()*
  471. char2nr({expr})
  472.         Return ASCII value of the first char in {expr}.  Examples:
  473. >            char2nr(" ")        returns 32
  474. >            char2nr("ABC")        returns 65
  475.  
  476.                             *col()*
  477. col({expr})    The result is a Number, which is the column of the file
  478.         position given with {expr}.  The accepted positions are:
  479.             .        the cursor position
  480.             'x        position of mark x (if the mark is not set, 0 is
  481.                 returned)
  482.         Note that only marks in the current file can be used.
  483.         Examples:
  484. >            col(".")        column of cursor
  485. >            col("'t")        column of mark t
  486. >            col("'" . markname)    column of mark markname
  487.         The first column is 1.  0 is returned for an error.
  488.  
  489.                             *confirm()*
  490. confirm({msg}, {choices}[, {default} [, {type}]])
  491.         Note: confirm() is only supported when compiled with dialog
  492.         support, see |+dialog_con|.
  493.         {msg} is displayed in a |dialog| with {choices} as the
  494.         alternatives.  {default} is the number of the choice that is
  495.         made if the user hits <CR>.  If {default} is omitted, 0 is
  496.         used.
  497.         {msg} is a String, use '\n' to include a newline.  Only on
  498.         some systems the string is wrapped when it doesn't fit.
  499.         {choices} is a String, with the individual choices separated
  500.         by '\n', e.g.
  501. >            "Yes\nNo\nCancel"
  502.         By default, the first letter of each choice is used as the
  503.         shortcut key; in the above example the keys y, n, and c would
  504.         choose the respective option.  To override this, put a '&'
  505.         before the letter you want to use:
  506. >            "Save\nSave &All"
  507.         The optional {type} argument gives the type of dialog.  This
  508.         is only used for the icon of the Win32 GUI.  It can be one of
  509.         these values: "Error", "Question", "Info", "Warning" or
  510.         "Generic".  Only the first character is relevant.
  511.         If the user aborts the dialog by pressing <Esc>, CTRL-C,
  512.         or another valid interrupt key, confirm() returns 0.
  513.  
  514.         An example:
  515. >   :let choice = confirm("What do you want?", "Apples\nOranges\nBananas", 2)
  516. >   :if choice == 0
  517. >   :    echo "make up your mind!"
  518. >   :elseif choice == 3
  519. >   :    echo "tasteful"
  520. >   :else
  521. >   :    echo "I prefer bananas myself."
  522. >   :endif
  523.         In a GUI dialog, buttons are used.  The layout of the buttons
  524.         depends on the 'confirm' option.  If it is "vertical", the
  525.         buttons are always put vertically.  Otherwise,  confirm()
  526.         tries to put the buttons in one horizontal line.  If they
  527.         don't fit, a vertical layout is used.
  528.  
  529.                             *delete()*
  530. delete({fname})    Deletes the file by the name {fname}.  The result is a Number,
  531.         which is 0 if the file was deleted successfully, and non-zero
  532.         when the deletion failed.
  533.  
  534.                             *escape()*
  535. escape({string}, {chars})
  536.         Escape the characters in {chars} that occur in {string} with a
  537.         backslash.  Example:
  538. >            :echo escape('c:\program files\vim', ' \')
  539.         results in:
  540. >            c:\\program\ files\\vim
  541.  
  542.                             *exists()*
  543. exists({expr})    The result is a Number, which is 1 if {var} is defined, zero
  544.         otherwise.  The {expr} argument is a string, which contains
  545.         one of these:
  546.             &option-name      Vim option
  547.             $ENVNAME      environment variable (could also be
  548.                       done by comparing with an empty
  549.                       string)
  550.             varname          internal variable (see
  551.                       |internal-variables|).
  552.  
  553.         Examples:
  554. >            exists("&shortname")
  555. >            exists("$HOSTNAME")
  556. >            exists("bufcount")
  557.         Note that the argument must be a string, not the name of the
  558.         variable itself!  This doesn't check for existence of the
  559.         "bufcount" variable, but gets the contents of "bufcount", and
  560.         checks if that exists:
  561.             exists(bufcount)
  562.  
  563.                             *expand()*
  564. expand({expr})    Expand the file wildcards in {expr}.  The result is a String.
  565.         When there are several matches, they are separated by <NL>
  566.         characters.  [Note: in version 5.0 a space was used, which
  567.         caused problems when a file name contains a space]
  568.         For Unix, backticks can be used to get the output of any
  569.         command.  Example:
  570. >            :let tagfiles = expand("`find . -name tags -print`")
  571. >            :let &tags = substitute(tagfiles, "\n", ",", "g")
  572.  
  573.         If the expansion fails, the result is an empty string.
  574.  
  575.         When the result of {expr} starts with '%', '#' or '<', the
  576.         expansion is done like for the |cmdline-special| variables
  577.         with their associated modifiers.  Here is a short overview:
  578.  
  579.         %            current file name
  580.         #            alternate file name
  581.         #n            alternate file name n
  582.         <cfile>            file name under the cursor
  583.         <afile>            autocmd file name
  584.         <abuf>            autocmd buffer number
  585.         <sfile>            sourced script file name
  586.         <cword>            word under the cursor
  587.         <cWORD>            WORD under the cursor
  588.     Modifiers:
  589.         :p            expand to full path
  590.         :h            head (last path component removed)
  591.         :t            tail (last path component only)
  592.         :r            root (one extension removed)
  593.         :e            extension only
  594.  
  595.         Example:
  596. >            :let &tags = expand("%:p:h") . "/tags"
  597.  
  598.         There cannot be white space between the variables and the
  599.         following modifier.  The |fnamemodify()| function can be used
  600.         to modify normal file names.
  601.  
  602.         When using '%' or '#', and the current or alternate file name
  603.         is not defined, an empty string is used.  Using "%:p" in a
  604.         buffer with no name, results in the current directory, with a
  605.         '/' added.
  606.  
  607.                             *filereadable()*
  608. filereadable({file})
  609.         The result is a Number, which is TRUE when a file with the
  610.         name {file} exists, and can be read.  If {file} doesn't exist,
  611.         or is a directory, the result is FALSE.  {file} is any
  612.         expression, which is used as a String.
  613.                             *file_readable()*
  614.         Obsolete name: file_readable().
  615.  
  616.                             *fnamemodify()*
  617. fnamemodify({fname}, {mods})
  618.         Modify file name {fname} accoding to {mods}.  {mods} is a
  619.         string of characters like it is used for file names on the
  620.         command line.  See |filename-modifiers|.
  621.         Example:
  622. >            :echo fnamemodify("main.c", ":p:h")
  623.         results in:
  624. >            /home/mool/vim/vim/src/
  625.  
  626.                             *getcwd()*
  627. getcwd()    The result is a String, which is the name of the current
  628.         working directory.
  629.  
  630.                             *getline()*
  631. getline({lnum}) The result is a String, which is line {lnum} from the current
  632.         buffer.  Example:
  633. >            getline(1)
  634.         When {lnum} is a String that doesn't start with a
  635.         digit, line() is called to translate the String into a Number.
  636.         To get the line under the cursor:
  637. >            getline(".")
  638.         When {lnum} is smaller than 1 or bigger than the number of
  639.         lines in the buffer, an empty string is returned.
  640.  
  641.                             *has()*
  642. has({feature})    The result is a Number, which is 1 if the feature {feature} is
  643.         supported, zero otherwise.  The {feature} argument is a
  644.         string.  See |feature-list| below.
  645.  
  646.                             *hlexists()*
  647. hlexists({name})
  648.         The result is a Number, which is non-zero if a highlight group
  649.         called {name} exists.  This is when the group has been
  650.         defined in some way.  Not necessarily when highlighting has
  651.         been defined for it, it may also have been used for a syntax
  652.         item.
  653.                             *highlight_exists()*
  654.         Obsolete name: highlight_exists().
  655.  
  656.                             *hlID()*
  657. hlID({name})    The result is a Number, which is the ID of the highlight group
  658.         with name {name}.  When the highlight group doesn't exist,
  659.         zero is returned.
  660.         This can be used to retrieve information about the highlight
  661.         group.  For example, to get the background color of the
  662.         "Comment" group:
  663. >    :echo synIDattr(synIDtrans(hlID("Comment")), "bg")
  664.                             *highlightID()*
  665.         Obsolete name: highlightID().
  666.  
  667.                             *hostname()*
  668. hostname()
  669.         The result is a String, which is the name of the machine on
  670.         which Vim is currently running. Machine names greater than
  671.         256 characters long are truncated.
  672.  
  673. input({prompt})                        *input()*
  674.         The result is a String, which is whatever the user typed on
  675.         the command-line.  The parameter is either a prompt string, or
  676.         a blank string (for no prompt).  A '\n' can be used in the
  677.         prompt to start a new line.  The highlighting set with
  678.         |:echohl| is used for the prompt.  The input is entered just
  679.         like a command-line, with the same editing commands and
  680.         mappings.  There is a separate history for lines typed for
  681.         input().
  682.         NOTE: This must not be used in a startup file, for the
  683.         versions that only run in GUI mode (e.g., the Win32 GUI).
  684.  
  685.         Example:
  686. >    :let choice = input("What is your choice? ")
  687.  
  688.                             *isdirectory()*
  689. isdirectory({directory})
  690.         The result is a Number, which is TRUE when a directory with
  691.         the name {directory} exists.  If {directory} doesn't exist, or
  692.         isn't a directory, the result is FALSE.  {directory} is any
  693.         expression, which is used as a String.
  694.  
  695.                             *line()*
  696. line({expr})    The result is a Number, which is the line number of the file
  697.         position given with {expr}.  The accepted positions are:
  698.             .        the cursor position
  699.             $        the last line in the current buffer
  700.             'x        position of mark x (if the mark is not set, 0 is
  701.                 returned)
  702.         Note that only marks in the current file can be used.
  703.         Examples:
  704. >            line(".")        line number of the cursor
  705. >            line("'t")        line number of mark t
  706. >            line("'" . marker)    line number of mark marker
  707.  
  708.                             *match()*
  709. match({expr}, {pat})
  710.         The result is a Number, which gives the index in {expr} where
  711.         {pat} matches.  A match at the first character returns zero.
  712.         If there is no match -1 is returned.  Example:
  713. >            :echo match("testing", "ing")
  714.         results in "4".
  715.         See |pattern| for the patterns that are accepted.
  716.         The 'ignorecase' option is used to set the ignore-caseness of
  717.         the pattern.  'smartcase' is NOT used.
  718.  
  719.                             *matchend()*
  720. matchend({expr}, {pat})
  721.         Same as match(), but return the index of first character after
  722.         the match.  Example:
  723. >            :echo matchend("testing", "ing")
  724.         results in "7".
  725.  
  726.                             *matchstr()*
  727. matchstr({expr}, {pat})
  728.         Same as match(), but return the matched string.  Example:
  729. >            :echo matchstr("testing", "ing")
  730.         results in "ing".
  731.         When there is no match "" is returned.
  732.  
  733.                             *nr2char()*
  734. nr2char({expr})
  735.         Return a string with a single chararacter, which has the ASCII
  736.         value {expr}.  Examples:
  737. >            nr2char(64)        returns "@"
  738. >            nr2char(32)        returns " "
  739.  
  740.                             *setline()*
  741. setline({lnum}, {line})
  742.         Set line {lnum} of the current buffer to {line}.  If this
  743.         succeeds, 0 is returned.  If this fails (most likely because
  744.         {lnum} is invalid) 1 is returned.  Example:
  745. >            :call setline(5, strftime("%c"))
  746.  
  747.                             *strftime()*
  748. strftime({format})
  749.         The result is a String, which is the current date and time, as
  750.         specified by the {format} string.  See the manual page of the
  751.         C function strftime() for the format.  The maximum length of
  752.         the result is 80 characters.  Examples:
  753. >          :echo strftime("%c")           Sun Apr 27 11:49:23 1997
  754. >          :echo strftime("%Y %b %d %X")       1997 Apr 27 11:53:25
  755. >          :echo strftime("%y%m%d %T")       970427 11:53:55
  756. >          :echo strftime("%H:%M")       11:55
  757.  
  758.                             *strlen()*
  759. strlen({expr})    The result is a Number, which is the length of the String
  760.         {expr}.
  761.  
  762.                             *strpart()*
  763. strpart({src}, {start}, {len})
  764.         The result is a String, which is part of {src},
  765.         starting from character {start}, with the length {len}.
  766.         When non-existing characters are included, this doesn't result
  767.         in an error, the characters are simply omitted.
  768. >            strpart("abcdefg", 3, 2)    == "de"
  769. >            strpart("abcdefg", -2, 4)   == "ab"
  770. >            strpart("abcdefg", 5, 4)    == "fg"
  771.         Note: To get the first character, {start} must be 0.  For
  772.         example, to get three characters under and after the cursor:
  773. >            strpart(getline(line(".")), col(".") - 1, 3)
  774.  
  775.                             *synID()*
  776. synID({line}, {col}, {trans})
  777.         The result is a Number, which is the syntax ID at the position
  778.         {line} and {col} in the current window.
  779.         The syntax ID can be used with |synIDattr()| and
  780.         |synIDtrans()| to obtain syntax information about text.
  781.         {col} is 1 for the leftmost column, {line} is 1 for the first
  782.         line.
  783.         When {trans} is non-zero, transparent items are reduced to the
  784.         item that they reveal.  This is useful when wanting to know
  785.         the effective color.  When {trans} is zero, the transparent
  786.         item is returned.  This is useful when wanting to know which
  787.         syntax item is effective (e.g. inside parens).
  788.         Warning: This function can be very slow.  Best speed is
  789.         obtained by going through the file in forward direction.
  790.  
  791.         Example (echos the name of the syntax item under the cursor):
  792. >            :echo synIDattr(synID(line("."), col("."), 1), "name")
  793.  
  794.                             *synIDattr()*
  795. synIDattr({synID}, {what} [, {mode}])
  796.         The result is a String, which is the {what} attribute of
  797.         syntax ID {synID}.  This can be used to obtain information
  798.         about a syntax item.
  799.         {mode} can be "gui", "cterm" or "term", to get the attributes
  800.         for that mode.  When {mode} is omitted, or an invalid value is
  801.         used, the attributes for the currently active highlighting are
  802.         used (GUI, cterm or term).
  803.         Use synIDtrans() to follow linked highlight groups.
  804.         {what}        result
  805.         "name"        the name of the syntax item
  806.         "fg"        foreground color (GUI: color name, cterm:
  807.                 color number as a string, term: empty string)
  808.         "bg"        background color (like "fg")
  809.         "fg#"        like "fg", but name in "#RRGGBB" form
  810.         "bg#"        like "bg", but name in "#RRGGBB" form
  811.         "bold"        "1" if bold
  812.         "italic"    "1" if italic
  813.         "reverse"    "1" if reverse
  814.         "inverse"    "1" if inverse (= reverse)
  815.         "underline"    "1" if underlined
  816.  
  817.         When the GUI is not running or the cterm mode is asked for,
  818.         "fg#" is equal to "fg" and "bg#" is equal to "bg".
  819.  
  820.         Example (echos the color of the syntax item under the cursor):
  821. >    :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")
  822.  
  823.                             *synIDtrans()*
  824. synIDtrans({synID})
  825.         The result is a Number, which is the translated syntax ID of
  826.         {synID}.  This is the syntax group ID of what is being used to
  827.         highlight the character.  Highlight links are followed.
  828.  
  829.                             *substitute()*
  830. substitute({expr}, {pat}, {sub}, {flags})
  831.         The result is a String, which is a copy of {expr}, in which
  832.         the first match of {pat} is replaced with {sub}.  This works
  833.         like the ":substitute" command (without any flags).  But the
  834.         'magic' option is ignored, the {pat} is always processed as if
  835.         'magic' is set (to make scripts portable).  And a "~" in {sub}
  836.         is not replaced with the previous {sub}.
  837.         When {pat} does not match in {expr}, {expr} is returned
  838.         unmodified.
  839.         When {flags} is "g", all matches of {pat} in {expr} are
  840.         replaced.  Otherwise {flags} should be "".
  841.         Example:
  842. >            :let &path = substitute(&path, ",\\=[^,]*$", "", "")
  843.         This removes the last component of the 'path' option.
  844. >            :echo substitute("testing", ".*", "\\U\\0", "")
  845.         results in "TESTING".
  846.  
  847.                             *tempname()*
  848. tempname()
  849.         The result is a String, which is the name of a file that
  850.         doesn't exist.  It can be used for a temporary file.  The name
  851.         is different for each least 26 consecutive calls.  Example:
  852. >            let tmpfile = tempname()
  853. >            exe "redir > " . tmpfile
  854.  
  855.                             *virtcol()*
  856. virtcol({expr})
  857.         The result is a Number, which is the screen column of the file
  858.         position given with {expr}.  That is, the last screen position
  859.         occupied by the character at that position, when the screen
  860.         would be of unlimited width.  When there is a <Tab> at the
  861.         position, the returned Number will be the column at the end of
  862.         the <Tab>.  For example, for a <Tab> in column 1, with 'ts'
  863.         set to 8, it returns 8;
  864.         The accepted positions are:
  865.             .        the cursor position
  866.             'x        position of mark x (if the mark is not set, 0 is
  867.                 returned)
  868.         Note that only marks in the current file can be used.
  869.         Examples:
  870. >  virtcol(".")        with text "foo^Lbar", with cursor on the "^L", returns 5
  871. >  virtcol("'t")    with text "    there", with 't at 'h', returns 6
  872.         The first column is 1.  0 is returned for an error.
  873.  
  874.                             *winbufnr()*
  875. winbufnr({nr})    The result is a Number, which is the number of the buffer
  876.         associated with window {nr}. When {nr} is zero, the number of
  877.         the buffer in the current window is returned.  When window
  878.         {nr} doesn't exist, -1 is returned.
  879.         Example:
  880. >  echo "The file in the current window is " . bufname(winbufnr(0))
  881.  
  882.                             *winheight()*
  883. winheight({nr})
  884.         The result is a Number, which is the height of window {nr}.
  885.         When {nr} is zero, the height of the current window is
  886.         returned.  When window {nr} doesn't exist, -1 is returned.
  887.         An existing window always has a height of zero or more.
  888.         Examples:
  889. >  echo "The current window has " . winheight(0) . " lines."
  890.  
  891.                             *winnr()*
  892. winnr()        The result is a Number, which is the number of the current
  893.         window.  The top window has number 1.
  894.  
  895.                             *feature-list*
  896. There are two types of features:
  897. 1.  Features that are only supported when they have been enabled when Vim
  898.     was compiled |+feature-list|.  Example:
  899. >        :if has("cindent")
  900. 2.  Features that are only supported when certain conditions have been met.
  901.     Example:
  902. >        :if has("gui_running")
  903.  
  904. all_builtin_terms    Compiled with all builtin terminals enabled.
  905. amiga            Amiga version of Vim.
  906. arp            Compiled with ARP support (Amiga).
  907. autocmd            Compiled with autocommands support.
  908. beos            BeOS version of Vim.
  909. browse            Compiled with |:browse| support, and browse() will
  910.             work.
  911. builtin_terms        Compiled with some builtin terminals.
  912. cindent            Compiled with 'cindent' support.
  913. cscope            Compiled with |cscope| support.
  914. compatible        Compiled to be very Vi compatible.
  915. debug            Compiled with "DEBUG" defined.
  916. dialog_con        Compiled with console dialog support.
  917. dialog_gui        Compiled with GUI dialog support.
  918. digraphs        Compiled with support for digraphs.
  919. dos32            32 bits DOS (DJGPP) version of Vim.
  920. dos16            16 bits DOS version of Vim.
  921. emacs_tags        Compiled with support for Emacs tags.
  922. eval            Compiled with expression evaluation support.  Always
  923.             true, of course!
  924. ex_extra        Compiled with extra Ex commands |+ex_extra|.
  925. extra_search        Compiled with support for |'incsearch'| and
  926.             |'hlsearch'|
  927. farsi            Compiled with Farsi support |farsi|.
  928. file_in_path        Compiled with support for |gf| and |<cfile>|
  929. filetype        Compiled with support for filetypes |+filetype|
  930. find_in_path        Compiled with support for include file searches
  931.             |+find_in_path|.
  932. fname_case        Case in file names matters (for Amiga, MS-DOS, and
  933.             Windows this is not present).
  934. fork            Compiled to use fork()/exec() instead of system().
  935. gui            Compiled with GUI enabled.
  936. gui_athena        Compiled with Athena GUI.
  937. gui_beos        Compiled with BeOs GUI.
  938. gui_mac            Compiled with Macintosh GUI.
  939. gui_motif        Compiled with Motif GUI.
  940. gui_win32        Compiled with MS Windows Win32 GUI.
  941. gui_win32s        idem, and Win32s system being used (Windows 3.1)
  942. gui_running        Vim is running in the GUI, or it will start soon.
  943. insert_expand        Compiled with support for CTRL-X expansion commands in
  944.             Insert mode.
  945. langmap            Compiled with 'langmap' support.
  946. lispindent        Compiled with support for lisp indenting.
  947. mac            Macintosh version of Vim.
  948. modify_fname        Compiled with file name modifiers. |filename-modifiers|
  949. mouse            Compiled with support mouse.
  950. mouse_dec        Compiled with support for Dec terminal mouse.
  951. mouse_netterm        Compiled with support for netterm mouse.
  952. mouse_xterm        Compiled with support for xterm mouse.
  953. multi_byte        Compiled with support for Korean et al.
  954. multi_byte_ime        Compiled with support for IME input method
  955. ole            Compiled with OLE automation support for Win32.
  956. perl            Compiled with Perl interface.
  957. python            Compiled with Python interface.
  958. quickfix        Compiled with |quickfix| support.
  959. rightleft        Compiled with 'rightleft' support.
  960. showcmd            Compiled with 'showcmd' support.
  961. smartindent        Compiled with 'smartindent' support.
  962. sniff            Compiled with SniFF interface support.
  963. syntax            Compiled with syntax highlighting support.
  964. syntax_items        There are active syntax highlighting items for the
  965.             current buffer.
  966. system            Compiled to use system() instead of fork()/exec().
  967. tag_binary        Compiled with binary searching in tags files
  968.             |tag-binary-search|.
  969. tag_old_static        Compiled with support for old static tags
  970.             |tag-old-static|.
  971. tag_any_white        Compiled with support for any white characters in tags
  972.             files |tag-any-white|.
  973. tcl            Compiled with Tcl interface.
  974. terminfo        Compiled with terminfo instead of termcap.
  975. textobjects        Compiled with support for |text-objects|.
  976. tgetent            Compiled with tgetent support, able to use a termcap
  977.             or terminfo file.
  978. unix            Unix version of Vim.
  979. user-commands        User-defined commands.
  980. viminfo            Compiled with viminfo support.
  981. vms            VMS version of Vim.
  982. wildignore        Compiled with 'wildignore' option
  983. win32            Win32 version of Vim (Windows 95/NT)
  984. writebackup        Compiled with 'writebackup' default on.
  985. xterm_save        Compiled with support for saving and restoring the
  986.             xterm screen.
  987. x11            Compiled with X11 support.
  988.  
  989. ==============================================================================
  990. 5. Defining functions                    *user-functions*
  991.  
  992. New functions can be defined.  These can be called with "Name()", just like
  993. builtin functions.  The name must start with an uppercase letter, to avoid
  994. confusion with builtin functions.
  995.  
  996.                             *:fu* *:function*
  997. :fu[nction]        List all functions and their arguments.
  998.  
  999. :fu[nction] {name}    List function {name}.
  1000.  
  1001. :fu[nction][!] {name}([arguments]) [range] [abort]
  1002.             Define a new function by the name {name}.  The name
  1003.             must be made of alphanumeric characters and '_', and
  1004.             must start with a capital.
  1005.             An argument can be defined by giving its name.  In the
  1006.             function this can then be used as "a:name" ("a:" for
  1007.             argument).
  1008.             Several arguments can be given, separated by commas.
  1009.             Finally, an argument "..." can be specified, which
  1010.             means that more arguments may be following.  In the
  1011.             function they can be used as "a:1", "a:2", etc.  "a:0"
  1012.             is set to the number of extra arguments (which can be
  1013.             0).
  1014.             When not using "...", the number of arguments in a
  1015.             function call must be equal the number of named
  1016.             arguments.  When using "...", the number of arguments
  1017.             may be larger.
  1018.             It is also possible to define a function without any
  1019.             arguments.  You must still supply the () then.
  1020.             The body of the function follows in the next lines,
  1021.             until ":endfunction".
  1022.             When a function by this name already exists and [!] is
  1023.             not used an error message is given.  When [!] is used,
  1024.             an existing function is silently replaced.
  1025.             When the [range] argument is added, the function is
  1026.             expected to take care of a range itself.  The range is
  1027.             passed as "a:firstline" and "a:lastline".  If [range]
  1028.             is excluded, a ":call" with a range will call the
  1029.             function for each line, with the cursor on the start
  1030.             of each line.
  1031.             When the [abort] argument is added, the function will
  1032.             abort as soon as an error is detected.
  1033.             The last used search pattern and the redo command "."
  1034.             will not be changed by the function.
  1035.  
  1036.                             *:endf* *:endfunction*
  1037. :endf[unction]        The end of a function definition.
  1038.  
  1039.                             *:delf* *:delfunction*
  1040. :delf[unction] {name}    Delete function {name}.
  1041.  
  1042.                             *:retu* *:return*
  1043. :retu[rn] [expr]    Return from a function.  When "[expr]" is given, it is
  1044.             evaluated and returned as the result of the function.
  1045.             If "[expr]" is not given, the number 0 is returned.
  1046.             When a function ends without an explicit ":return",
  1047.             the number 0 is returned.
  1048.             Note that there is no check for unreachable lines,
  1049.             thus there is no warning if commands follow ":return".
  1050.  
  1051. Inside a function variables can be used.  These are local variables, which
  1052. will disappear when the function returns.  Global variables need to be
  1053. accessed with "g:".
  1054.  
  1055. Example:
  1056. >  :function Table(title, ...)
  1057. >  :  echohl Title
  1058. >  :  echo a:title
  1059. >  :  echohl None
  1060. >  :  let idx = 1
  1061. >  :  while idx <= a:0
  1062. >  :    exe "echo a:" . idx
  1063. >  :    let idx = idx + 1
  1064. >  :  endwhile
  1065. >  :  return idx
  1066. >  :endfunction
  1067.  
  1068. This function can then be called with:
  1069. >  let lines = Table("Table", "line1", "line2")
  1070. >  let lines = Table("Empty Table")
  1071.  
  1072. To return more than one value, pass the name of a global variable:
  1073. >  :function Compute(n1, n2, divname)
  1074. >  :  if a:n2 == 0
  1075. >  :    return "fail"
  1076. >  :  endif
  1077. >  :  exe "let " . a:divname . " = ". a:n1 / a:n2
  1078. >  :  return "ok"
  1079. >  :endfunction
  1080.  
  1081. This function can then be called with:
  1082. >  :let success = Compute(13, 1324, "div")
  1083. >  :if success == "ok"
  1084. >  :  echo div
  1085. >  :endif
  1086.  
  1087.                             *:cal* *:call*
  1088. :[range]cal[l] {name}([arguments])
  1089.         Call a function.  The name of the function and its arguments
  1090.         are as before.
  1091.         Without a range and for functions that accept a range, the
  1092.         function is called once, with the cursor at the current
  1093.         position.
  1094.         When a range is given and the function doesn't handle it
  1095.         itself, the function is executed for each line in the range,
  1096.         with the cursor in the first column of that line.  The cursor
  1097.         is left at the last line (possibly moved by the last function
  1098.         call).  The arguments are re-evaluated for each line.  Thus
  1099.         this works:
  1100.  
  1101. >    :function Mynumber(arg)
  1102. >    :  echo line(".") . " " . a:arg
  1103. >    :endfunction
  1104. >    :1,5call Mynumber(getline("."))
  1105.  
  1106. The recursiveness of user functions is restricted with the |'maxfuncdepth'|
  1107. option.
  1108.  
  1109. ==============================================================================
  1110. 6. Commands                        *expression-commands*
  1111.  
  1112. :let {var-name} = {expr1}                *:let*
  1113.             Set internal variable {var-name} to the result of the
  1114.             expression {expr1}.  The variable will get the type
  1115.             from the {expr}.  if {var-name} didn't exist yet, it
  1116.             is created.
  1117.  
  1118. :let ${env-name} = {expr1}            *:let-environment* *:let-$*
  1119.             Set environment variable {env-name} to the result of
  1120.             the expression {expr1}.  The type is always String.
  1121.  
  1122. :let @{reg-name} = {expr1}            *:let-register* *:let-@*
  1123.             Write the result of the expression {expr1} in register
  1124.             {reg-name}.  {reg-name} must be a single letter, and
  1125.             must be the name of a writable register (see
  1126.             |registers|).  "@@" can be used for the unnamed
  1127.             register.  If the result of {expr1} ends in a <CR> or
  1128.             <NL>, the register will be linewise, otherwise it will
  1129.             be set to characterwise.
  1130.  
  1131. :let &{option-name} = {expr1}            *:let-option* *:let-star*
  1132.             Set option {option-name} to the result of the
  1133.             expression {expr1}.  The type of the option is always
  1134.             used.
  1135.  
  1136.                             *:unlet* *:unl*
  1137. :unl[et][!] {var-name} ...
  1138.             Remove the internal variable {var-name}.  Several
  1139.             variable names can be given, they are all removed.
  1140.             With [!] no error message is given for non-existing
  1141.             variables.
  1142.  
  1143. :if {expr1}                        *:if* *:endif* *:en*
  1144. :en[dif]        Execute the commands until the next matching ":else"
  1145.             or ":endif" if {expr1} evaluates to non-zero.
  1146.  
  1147.             From Vim version 4.5 until 5.0, every Ex command in
  1148.             between the ":if" and ":endif" is ignored.  These two
  1149.             commands were just to allow for future expansions in a
  1150.             backwards compatible way.  Nesting was allowed.  Note
  1151.             that any ":else" or ":elseif" was ignored, the "else"
  1152.             part was not executed either.
  1153.  
  1154.             You can use this to remain compatible with older
  1155.             versions:
  1156. >                :if version >= 500
  1157. >                :  version-5-specific-commands
  1158. >                :endif
  1159.  
  1160.                             *:else* *:el*
  1161. :el[se]            Execute the commands until the next matching ":else"
  1162.             or ":endif" if they previously were not being
  1163.             executed.
  1164.  
  1165.                             *:elseif* *:elsei*
  1166. :elsei[f] {expr1}    Short for ":else" ":if", with the addition that there
  1167.             is no extra ":endif".
  1168.  
  1169. :wh[ile] {expr1}            *:while* *:endwhile* *:wh* *:endw*
  1170. :endw[hile]        Repeat the commands between ":while" and ":endwhile",
  1171.             as long as {expr1} evaluates to non-zero.
  1172.             When an error is detected from a command inside the
  1173.             loop, execution continues after the "endwhile".
  1174.  
  1175.         NOTE: The ":append" and ":insert" commands don't work properly
  1176.         inside a ":while" loop.
  1177.  
  1178.                             *:continue* *:con*
  1179. :con[tinue]        When used inside a ":while", jumps back to the
  1180.             ":while".
  1181.  
  1182.                             *:break* *:brea*
  1183. :brea[k]        When used inside a ":while", skips to the command
  1184.             after the matching ":endwhile".
  1185.  
  1186.                             *:ec* *:echo*
  1187. :ec[ho] {expr1} ..    Echoes each {expr1}, with a space in between and a
  1188.             terminating <EOL>.  Also see |:comment|.
  1189.             Example:
  1190. >        :echo "the value of 'shell' is" &shell
  1191.  
  1192.                             *:echon*
  1193. :echon {expr1} ..    Echoes each {expr1}, without anything added.  Also see
  1194.             |:comment|.
  1195.             Example:
  1196. >        :echon "the value of 'shell' is " &shell
  1197.  
  1198.             Note the difference between using ":echo", which is a
  1199.             Vim command, and ":!echo", which is an external shell
  1200.             command:
  1201. >        :!echo %        --> filename
  1202.             The arguments of ":!" are expanded, see |:_%|.
  1203. >        :!echo "%"        --> filename or "filename"
  1204.             Like the previous example.  Whether you see the double
  1205.             quotes or not depends on your 'shell'.
  1206. >        :echo %            --> nothing
  1207.             The '%' is an illegal character in an expression.
  1208. >        :echo "%"        --> %
  1209.             This just echoes the '%' character.
  1210. >        :echo expand("%")    --> filename
  1211.             This calls the expand() function to expand the '%'.
  1212.  
  1213.                             *:echoh* *:echohl*
  1214. :echoh[l] {name}    Use the highlight group {name} for the following
  1215.             ":echo[n]" commands.  Example:
  1216. >        :echohl WarningMsg | echo "Don't panic!" | echohl None
  1217.             Don't forget to set the group back to "None",
  1218.             otherwise all following echo's will be highlighted.
  1219.  
  1220.                             *:exe* *:execute*
  1221. :exe[cute] {expr1} ..    Executes the string that results from the evaluation
  1222.             of {expr1} as an Ex command.  Multiple arguments are
  1223.             concatenated, with a space in between.  Examples:
  1224. >        :execute "buffer " nextbuf
  1225. >        :execute "normal " count . "w"
  1226.  
  1227.             Execute can be used to append a next command to
  1228.             commands that don't accept a '|'.  Example:
  1229. >        :execute '!ls' | echo "theend"
  1230.  
  1231.             Note: The executed string may be any command-line, but
  1232.             you cannot start or end a "while" or "if" command.
  1233.             Thus this is illegal:
  1234. >        :execute 'while i > 5'
  1235. >        :execute 'echo "test" | break'
  1236.  
  1237.             It is allowed to have a "while" or "if" command
  1238.             completely in the executed string:
  1239. >        :execute 'while i < 5 | echo i | let i = i + 1 | endwhile'
  1240.  
  1241.  
  1242.                             *:comment*
  1243.             ":execute", ":echo" and ":echon" cannot be followed by
  1244.             a comment directly, because they see the '"' as the
  1245.             start of a string.  But, you can use '|' followed by a
  1246.             comment.  Example:
  1247. >        :echo "foo" | "this is a comment
  1248.  
  1249.  
  1250.  vim:tw=78:ts=8:sw=8:
  1251.