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

  1. *cmdline.txt*   For Vim version 5.3.  Last modification: 1998 Jul 26
  2.  
  3.  
  4.           VIM REFERENCE MANUAL    by Bram Moolenaar
  5.  
  6.  
  7.                     *Cmdline-mode* *Command-line-mode*
  8. Command-line mode                    *mode-cmdline* *:*
  9.  
  10. Command-line mode is used to enter Ex commands (":"), search patterns
  11. ("/" and "?"), and filter commands ("!").
  12.  
  13. 1. Command-line editing        |cmdline-editing|
  14. 2. Command-line completion    |cmdline-completion|
  15. 3. Ex command-lines        |cmdline-lines|
  16. 4. Ex command-line ranges    |cmdline-ranges|
  17. 5. Ex special characters    |cmdline-special|
  18.  
  19. ==============================================================================
  20. 1. Command-line editing                    *cmdline-editing*
  21.  
  22. Normally characters are inserted in front of the cursor position.  You can
  23. move around in the command-line with the left and right cursor keys.  With the
  24. <Insert> key, you can toggle between inserting and overstriking characters.
  25. {Vi: can only alter the last character in the line}
  26.  
  27. Note that if your keyboard does not have working cursor keys or any of the
  28. other special keys, you can use ":cnoremap" to define another key for them.
  29. For example, to define tcsh style editing keys:        *tcsh-style*
  30. >    :cnoremap <C-A> <Home>
  31. >    :cnoremap <C-F> <Right>
  32. >    :cnoremap <C-B> <Left>
  33. >    :cnoremap <Esc>b <S-Left>
  34. >    :cnoremap <Esc>f <S-Right>
  35. (<> notation |<>|; type all this literally)
  36.  
  37.                             *cmdline-history*
  38. The command-lines that you enter are remembered in a history table.  You can
  39. recall them with the up and down cursor keys.  There are actually four
  40. history tables:
  41. - one for ':' commands
  42. - one for search strings
  43. - one for expressions
  44. - one for input lines, typed for the |input()| function.
  45. These are completely separate.  Each history can only be accessed when
  46. entering the same type of line.
  47. Use the 'history' option to set the number of lines that are remembered
  48. (default: 20).
  49. Notes:
  50. - When you enter a command-line that is exactly the same as an older one, the
  51.   old one is removed (to avoid repeated commands moving older commands out of
  52.   the history).
  53. - Only commands that are typed are remembered.  Ones that completely come from
  54.   mappings are not put in the history
  55. - All searches are put in the search history, including the ones that come
  56.   from commands like "*" and "#".  But for a mapping, only the last search is
  57.   remembered (to avoid that long mappings trash the history).
  58. {Vi: no history}
  59.  
  60. There is an automatic completion of names on the command-line; see
  61. |cmdline-completion|.
  62.  
  63.                             *c_CTRL-V*
  64. CTRL-V        Insert next non-digit literally.  Up to three digits form the
  65.         decimal value of a single byte.  The non-digit and the three
  66.         digits are not considered for mapping.  This works the same
  67.         way as in Insert mode (see above, |i_CTRL-V|).
  68.                             *c_CTRL-Q*
  69. CTRL-Q        Same as CTRL-V.
  70.  
  71.                             *c_<Left>*
  72. <Left>        cursor left
  73.                             *c_<Right>*
  74. <Right>        cursor right
  75.                             *c_<S-Left>*
  76. <S-Left> or <C-Left>                    *c_<C-Left>*
  77.         cursor one WORD left
  78.                             *c_<S-Right>*
  79. <S-Right> or <C-Right>                    *c_<C-Right>*
  80.         cursor one WORD right
  81. CTRL-B or <Home>                    *c_CTRL-B* *c_<Home>*
  82.         cursor to beginning of command-line
  83. CTRL-E or <End>                        *c_CTRL-E* *c_<End>*
  84.         cursor to end of command-line
  85.  
  86.                             *c_<LeftMouse>*
  87. <LeftMouse>    cursor to position of mouse click.
  88.  
  89. CTRL-H                            *c_<BS>* *c_CTRL-H*
  90. <BS>        delete the character in front of the cursor (see |:fixdel| if
  91.         your <BS> key does not do what you want).
  92.                             *c_<Del>*
  93. <Del>        delete the character under the cursor (at end of line:
  94.         character before the cursor) (see |:fixdel| if your <Del>
  95.         key does not do what you want).
  96.                             *c_CTRL-W*
  97. CTRL-W        delete the word before the cursor
  98.                             *c_CTRL-U*
  99. CTRL-U        remove all characters
  100.  
  101.         Note: if the command-line becomes empty with one of the
  102.         delete commands, Command-line mode is quit.
  103.                             *c_<Insert>*
  104. <Insert>    Toggle between insert and overstrike.  {not in Vi}
  105.  
  106. {char1} <BS> {char2}    or                *c_digraph*
  107. CTRL-K {char1} {char2}                    *c_CTRL-K*
  108.         enter digraph (see |digraphs|).  When {char1} is a special
  109.         key, the code for that key is inserted.  {not in Vi}
  110.  
  111. CTRL-R <0-9a-z"%#:-=>                    *c_CTRL-R*
  112.         Insert the contents of a numbered or named register.  Between
  113.         typing CTRL-R and the second character '"' will be displayed
  114.         to indicate that you are expected to enter the name of a
  115.         register.  The text is inserted as if you typed it, but
  116.         mappings and abbreviations are not used.  Special registers:
  117.             '"'    the unnamed register, containing the text of
  118.                 the last delete or yank
  119.             '%'    the current file name
  120.             '#'    the alternate file name
  121.             ':'    the last command-line
  122.             '-'    the last small (less than a line) delete
  123.             '='    the expression register: you are prompted to
  124.                 enter an expression (see |expression|)
  125.         Note: The '.' register (last inserted text) is not available
  126.         here.  See |registers| about registers.  {not in Vi}
  127.  
  128. CTRL-J                        *c_CTRL-J* *c_<NL>* *c_<CR>*
  129. <CR> or <NL>    start entered command
  130.                             *c_<Esc>*
  131. <Esc>        When typed and 'x' not present in 'cpoptions', quit
  132.         Command-line mode without executing.  In macros or when 'x'
  133.         present in 'cpoptions', start entered command.
  134.                             *c_CTRL-C*
  135. CTRL-C        quit command-line without executing
  136.  
  137.                             *c_<Up>*
  138. <Up>        recall older command-line from history, whose beginning
  139.         matches the current command-line (see below).
  140.                             *c_<Down>*
  141. <Down>        recall more recent command-line from history, whose beginning
  142.         matches the current command-line (see below).
  143.  
  144.                             *c_<S-Up>* *c_<PageUp>*
  145. <S-Up> or <PageUp>
  146.         recall older command-line from history
  147.                         *c_<S-Down>* *c_<PageDown>*
  148. <S-Down> or <PageDown>
  149.         recall more recent command-line from history
  150.  
  151. CTRL-D        command-line completion (see |cmdline-completion|)
  152. 'wildchar' option
  153.         command-line completion (see |cmdline-completion|)
  154. CTRL-N        command-line completion (see |cmdline-completion|)
  155. CTRL-P        command-line completion (see |cmdline-completion|)
  156. CTRL-A        command-line completion (see |cmdline-completion|)
  157. CTRL-L        command-line completion (see |cmdline-completion|)
  158.  
  159.                             *c_CTRL-_*
  160. CTRL-_        a - switch between Hebrew and English keyboard mode, which is
  161.         private to the command-line and not related to hkmap.
  162.         This is useful when Hebrew text entry is required in the
  163.         command-line, searches, abbreviations, etc.  Applies only if
  164.         Vim is compiled with the |+rightleft| feature and the
  165.         'allowrevins' option is set.
  166.         See |rightleft.txt|.
  167.  
  168.         b - switch between Farsi and English keyboard mode, which is
  169.         private to the command-line and not related to fkmap.  In
  170.         Farsi keyboard mode the characters are inserted in reverse
  171.         insert manner.  This is useful when Farsi text entry is
  172.         required in the command-line, searches, abbreviations, etc.
  173.         Applies only if Vim is compiled with the |+farsi| feature.
  174.         See |farsi.txt|.
  175.  
  176. The <Up> and <Down> keys take the current command-line as a search string.
  177. The beginning of the next/previous command-lines are compared with this
  178. string.  The first line that matches is the new command-line.  When typing
  179. these two keys repeatedly, the same string is used again.  For example, this
  180. can be used to find the previous substitute command: Type ":s" and then <Up>.
  181. The same could be done by typing <S-Up> a number of times until the desired
  182. command-line is shown.  (Note: the shifted arrow keys do not work on all
  183. terminals)
  184.  
  185. ==============================================================================
  186. 2. Command-line completion                *cmdline-completion*
  187.  
  188. When editing the command-line, a few commands can be used to complete the
  189. word before the cursor.  This is available for:
  190.  
  191. - Command names: at the start of the command-line.  Works always.
  192. - tags: only after the ":tag" command.
  193. - file names: only after a command that accepts a file name or a setting for
  194.   an option that can be set to a file name.  This is called file name
  195.   completion.
  196. - options: only after the ":set" command.
  197.  
  198. These are the commands that can be used:
  199.  
  200.                             *c_CTRL-D*
  201. CTRL-D        List names that match the pattern in front of the cursor.
  202.         When showing file names, directories are highlighted (see
  203.         'highlight' option).  Names where 'suffixes' matches are moved
  204.         to the end.
  205.                     *c_CTRL-I* *c_wildchar* *c_<Tab>*
  206. 'wildchar' option
  207.         A match is done on the pattern in front of the cursor.  The
  208.         match (if there are several, the first match) is inserted
  209.         in place of the pattern.  (Note: does not work inside a
  210.         macro, because <Tab> or <Esc> are mostly used as 'wildchar',
  211.         and these have a special meaning in some macros.) When typed
  212.         again and there were multiple matches, the next
  213.         match is inserted.  After the last match, the first is used
  214.         again (wrap around).
  215.         The behaviour can be changed with the 'wildmode' option.
  216.                             *c_CTRL-N*
  217. CTRL-N        After using 'wildchar' which got multiple matches, go to next
  218.         match.  Otherwise recall more recent command-line from history.
  219. <S-Tab>                            *c_CTRL-P* *c_<S-Tab>*
  220. CTRL-P        After using 'wildchar' which got multiple matches, go to
  221.         previous match.  Otherwise recall older command-line from
  222.         history.  <S-Tab> only works with the GUI, on the Amiga and
  223.         with MS-DOS.
  224.                             *c_CTRL-A*
  225. CTRL-A        All names that match the pattern in front of the cursor are
  226.         inserted.
  227.                             *c_CTRL-L*
  228. CTRL-L        A match is done on the pattern in front of the cursor.  If
  229.         there is one match, it is inserted in place of the pattern.
  230.         If there are multiple matches the longest common part is
  231.         inserted in place of the pattern.  If the result is shorter
  232.         than the pattern, no completion is done.
  233.  
  234. The 'wildchar' option defaults to <Tab> (CTRL-E when in Vi compatible mode; in
  235. a previous version <Esc> was used).  In the pattern standard wildcards '*' and
  236. '?' are accepted.  '*' matches any string, '?' matches exactly one character.
  237.  
  238. If you like tcsh's autolist completion, you can use this mapping:
  239.     :cnoremap X <C-L><C-D>
  240. (Where X is the command key to use, <C-L> is CTRL-L and <C-D> is CTRL-D)
  241. This will find the longest match and then list all matching files.
  242.  
  243.                             *suffixes*
  244. For file name completion you can use the 'suffixes' option to set a priority
  245. between files with almost the same name.  If there are multiple matches,
  246. those files with an extension that is in the 'suffixes' option are ignored.
  247. The default is ".bak,~,.o,.h,.info,.swp", which means that files ending in
  248. ".bak", "~", ".o", ".h", ".info" and ".swp" are sometimes ignored.  It is
  249. impossible to ignore suffixes with two dots.  Examples:
  250.  
  251.   pattern:    files:                match:    ~
  252.    test*    test.c test.h test.o        test.c
  253.    test*    test.h test.o            test.h and test.o
  254.    test*    test.i test.h test.c        test.i and test.c
  255.  
  256. If there is more than one matching file (after ignoring the ones matching
  257. the 'suffixes' option) the first file name is inserted.  You can see that
  258. there is only one match when you type 'wildchar' twice and the completed
  259. match stays the same.  You can get to the other matches by entering
  260. 'wildchar', CTRL-N or CTRL-P.  All files are included, also the ones with
  261. extensions matching the 'suffixes' option.
  262.  
  263. The old value of an option can be obtained by hitting 'wildchar' just after
  264. the '='.  For example, typing 'wildchar' after ":set dir=" will insert the
  265. current value of 'dir'.  This overrules file name completion for the options
  266. that take a file name.
  267.  
  268. If you would like using <S-Tab> for CTRL-P in an xterm, put this command in
  269. your .cshrc:
  270. >    xmodmap -e "keysym Tab = Tab Find"
  271. And this in your .vimrc:
  272. >    cmap <Esc>[1~ <C-P>        (<C-P> is CTRL-P)
  273.  
  274. ==============================================================================
  275. 3. Ex command-lines                    *cmdline-lines*
  276.  
  277. The Ex commands have a few specialties:
  278.  
  279.                             *:quote*
  280. '"' at the start of a line causes the whole line to be ignored.  '"'
  281. after a command causes the rest of the line to be ignored.  This can be used
  282. to add comments.  Example:
  283. >    :set ai        "set 'autoindent' option
  284. It is not possible to add a comment to a shell command ":!cmd" or to the
  285. ":map" command and friends, because they see the '"' as part of their
  286. argument.
  287.  
  288.                             *:bar*
  289. '|' can be used to separate commands, so you can give multiple commands in one
  290. line.  If you want to use '|' as an argument, precede it with '\'.
  291.  
  292. These commands see the '|' as their argument, and can therefore not be
  293. followed by another command:
  294.     :autocmd
  295.     :global
  296.     :normal
  297.     :perl
  298.     :perldo
  299.     :pyfile
  300.     :python
  301.     :read !
  302.     :tcl
  303.     :tcldo
  304.     :tclfile
  305.     :vglobal
  306.     :write !
  307.     :[range]!
  308.  
  309. Note that this is confusing (inherited from Vi): With ":g" the '|' is included
  310. in the command, with ":s" it is not.
  311.  
  312. To be able to use another command anyway, use the ":execute" command.
  313. Example (append the output of "ls" and jump to the first line):
  314. >    :execute 'r !ls' | '[
  315.  
  316. There is one exception: When the 'b' flag is present in 'cpoptions', with the
  317. ":map" and ":abbr" commands and friends CTRL-V needs to be used instead of
  318. '\'.  You can also use "<Bar>" instead.  See also |map_bar|.
  319.  
  320. Examples:
  321. >    :!ls | wc        view the output of two commands
  322. >    :r !ls | wc        insert the same output in the text
  323. >    :%g/foo/p|>        moves all matching lines one shiftwidth
  324. >    :%s/foo/bar/|>        moves one line one shiftwidth
  325. >    :map q 10^V|        map "q" to "10|"
  326. >    :map q 10\| map \ l    map "q" to "10\" and map "\" to "l"
  327. >                    (when 'b' is present in 'cpoptions')
  328.  
  329. You can also use <NL> to separate commands in the same way as with '|'.  To
  330. insert a <NL> use CTRL-V CTRL-J.  "^@" will be shown.  Using '|' is the
  331. preferred method.  But for external commands a <NL> must be used, because a
  332. '|' is included in the external command.  To avoid the special meaning of <NL>
  333. it must be preceded with a backslash.  Example:
  334. >    :r !date<NL>-join
  335. This reads the current date into the file and joins it with the previous line.
  336.  
  337. Note that when the command before the '|' generates an error, the following
  338. commands will not be executed.
  339.  
  340.  
  341. Because of Vi compatibility the following strange commands are supported:
  342. >    :|            print current line (like ":p")
  343. >    :3|            print line 3 (like ":3p")
  344. >    :3            goto line 3
  345.  
  346. A colon is allowed between the range and the command name.  It is ignored
  347. (this is Vi compatible).  For example:
  348. >    :1,$:s/pat/string
  349.  
  350. When the character '%' or '#' is used where a file name is expected, they are
  351. expanded to the current and alternate file name (see the chapter "editing
  352. files" |:_%| |:_#|).
  353.  
  354. Embedded spaces in file names are allowed on the Amiga if one file name is
  355. expected as argument.  Trailing spaces will be ignored, unless escaped with a
  356. backslash or CTRL-V.  Note that the ":next" command uses spaces to separate
  357. file names.  Escape the spaces to include them in a file name.  Example:
  358. >    :next foo\ bar goes\ to school\
  359. starts editing the three files "foo bar", "goes to" and "school ".
  360.  
  361. When you want to use the special characters '"' or '|' in a command, or want
  362. to use '%' or '#' in a file name, precede them with a backslash.  The
  363. backslash is not required in a range and in the ":substitute" command.
  364.  
  365.                             *:_!*
  366. The '!' (bang) character after an Ex command makes the command behave in a
  367. different way.  The '!' should be placed immediately after the command, without
  368. any blanks in between.  If you insert blanks the '!' will be seen as an
  369. argument for the command, which has a different meaning.  For example:
  370.     :w! name    write the current buffer to file "name", overwriting
  371.             any existing file
  372.     :w !name    send the current buffer as standard input to command
  373.             "name"
  374.  
  375. ==============================================================================
  376. 4. Ex command-line ranges            *cmdline-ranges* *[range]*
  377.  
  378. Some Ex commands accept a line range in front of them.  This is noted as
  379. [range].  It consists of one or more line specifiers, separated with ',' or
  380. ';'.
  381.  
  382.                         *:,* *:;*
  383. When separated with ';' the cursor position will be set to that line
  384. before interpreting the next line specifier.  This doesn't happen for ','.
  385. Examples:
  386. >    4,/this line/        from line 4 till match with "this line" after
  387. >                the cursor line.
  388. >    5;/that line/        from line 5 till match with "that line" after
  389. >                line 5.
  390.  
  391. The default line specifier for most commands is the cursor position, but the
  392. commands ":write" and ":global" have the whole file (1,$) as default.
  393.  
  394. If more line specifiers are given than required for the command, the first
  395. one(s) will be ignored.
  396.  
  397. Line numbers may be specified with:            *:range*
  398.     {number}    an absolute line number
  399.     .        the current line              *:.*
  400.     $        the last line in the file          *:$*
  401.     %        equal to 1,$ (the entire file)          *:%*
  402.     't        position of mark t (lower case)          *:'*
  403.     /{pattern}[/]    the next line where {pattern} matches      *:/*
  404.     ?{pattern}[?]    the previous line where {pattern} matches *:?*
  405.     \/        the next line where the previously used search
  406.             pattern matches
  407.     \?        the previous line where the previously used search
  408.             pattern matches
  409.     \&        the next line where the previously used substitute
  410.             pattern matches
  411.  
  412. Each may be followed (several times) by '+' or '-' and an optional number.
  413. This number is added or subtracted from the preceding line number.  If the
  414. number is omitted, 1 is used.
  415.  
  416. The "/" and "?" after {pattern} are required to separate the pattern from
  417. anything that follows.
  418.  
  419. The "/" and "?" may be preceded with another address.  The search starts from
  420. there.  The difference from using ';' is that the cursor isn't moved.
  421. Examples:
  422. >    /pat1//pat2/    Find line containing "pat2" after line containing
  423. >            "pat1", without moving the cursor.
  424. >    7;/pat2/    Find line containing "pat2", after line 7, leaving
  425. >            the cursor in line 7.
  426.  
  427. The {number} must be between 0 and the number of lines in the file.  A 0 is
  428. interpreted as a 1, except with the commands tag, pop and read.
  429.  
  430. Examples:
  431. >    .+3        three lines below the cursor
  432. >    /that/+1    the line below the next line containing "that"
  433. >    .,$        from current line until end of file
  434. >    0;/that        the first line containing "that"
  435.  
  436. Some commands allow for a count after the command.  This count is used as the
  437. number of lines to be used, starting with the line given in the last line
  438. specifier (the default is the cursor line).  The commands that accept a count
  439. are the ones that use a range but do not have a file name argument (because
  440. a file name can also be a number).
  441.  
  442. Examples:
  443. >    :s/x/X/g 5    substitute 'x' by 'X' in the current line and four
  444. >            following lines
  445. >    :23d 4        delete lines 23, 24, 25 and 26
  446.  
  447. A range should have the lower line number first.  If this is not the case, Vim
  448. will ask you if it should swap the line numbers.  This is not done within the
  449. global command ":g".
  450.  
  451.                             *N:*
  452. When giving a count before entering ":", this is translated into:
  453.         :.,.+(count - 1)
  454. In words: The 'count' lines at and after the cursor.  Example: To delete
  455. three lines:
  456. >        3:d<CR>        is translated into: .,.+2d<CR>
  457.  
  458.                             *v_:*
  459. {Visual}:    Starts a command-line with the Visual selected lines as a
  460.         range.  The code ":'<,'>" is used for this range, which makes
  461.         it possible to select a similar line from the command-line
  462.         history for repeating a command on different Visually selected
  463.         lines.
  464.  
  465. ==============================================================================
  466. 5. Ex special characters                *cmdline-special*
  467.  
  468. In Ex commands, at places where a file name can be used, the following
  469. characters have a special meaning.  These can also be used in the expression
  470. function expand() |expand()|.
  471.     %       is replaced with the current file name        *:_%*
  472.     #       is replaced with the alternate file name        *:_#*
  473.     #n       (where n is a number) is replaced with the file name of
  474.            buffer n.  "#0" is the same as "#"
  475.  
  476. To avoid the special meaning of '%' and '#' insert a backslash before it.
  477. Detail: The special meaning is always escaped when there is a backslash before
  478. it, no matter how many backslashes.
  479.     you type:        result    ~
  480.        #            alternate.file
  481.        \#            #
  482.        \\#            \#
  483.  
  484.                    *:<cword>* *:<cWORD>* *:<cfile>* *<cfile>*
  485.                    *:<sfile>* *<sfile>* *:<afile>* *<afile>*
  486.                    *:<abuf>* *<abuf>*
  487. Note: the next four are typed literally, these are not special keys!
  488.     <cword>    is replaced with the word under the cursor
  489.     <cWORD>    is replaced with the WORD under the cursor (see |WORD|)
  490.     <cfile>    is replaced with the path name under the cursor
  491.     <afile>    when executing autocommands, is replaced with the file name
  492.            for a file read or write
  493.     <abuf>     when executing autocommands, is replaced with the currently
  494.            effective buffer number (for ":r file" it is the current
  495.            buffer, the file being read is not in a buffer).
  496.     <sfile>    when executing a ":source" command, is replaced with the
  497.            file name of the sourced file.
  498.  
  499.                              *filename-modifiers*
  500.          *:_%:* *::p* *::.* *::~* *::h* *::t* *::r* *::e* *::s* *::gs*
  501. The file name modifers can be used after "%", "#", "#n", "<cfile>", "<sfile>",
  502. "<afile>" or "<abuf>".  They are also used with the |fnamemodify()| function.
  503. These are not available when Vim has been compiled without the |+modify_fname|
  504. feature.
  505. These modifiers can be given, in this order:
  506.     :p    Make file name a full path.  Must be the first modifier.
  507.     :.    Reduce file name to be relative to current directory, if
  508.         possible.  File name is unmodifed if it is not below the
  509.         current directory.
  510.     :~    Reduce file name to be relative to the home directory, if
  511.         possible.  File name is unmodifed if it is not below the home
  512.         directory.
  513.         For maximum shortness, use ":~:.".
  514.     :h    Head of the file name (the last component and any separators
  515.         removed).  Cannot be used with :e, :r or :t.
  516.         Can be repeated to remove several components at the end.
  517.         When the file name is an absolute path (starts with "/" for
  518.         Unix; "x:\" for MS-DOS, WIN32, OS/2; "drive:" for Amiga), that
  519.         part is not removed.  When there is no head (path is relative
  520.         to current directory) the result is empty.
  521.     :t    Tail of the file name (last component of the name).  Must
  522.         precede any :r or :e.
  523.     :r    Root of the file name (the last extension removed).  When
  524.         there is only an extension (file name that starts with '.',
  525.         e.g., ".vimrc"), it is not removed.  Can be repeated to remove
  526.         several extensions (last one first).
  527.     :e    Extension of the file name.  Only makes sense when used alone.
  528.         When there is no extension the result is empty.
  529.         When there is only an extension (file name that starts with
  530.         '.'), the result is empty.  Can be repeated to include more
  531.         extensions.  If there are not enough extensions (but at least
  532.         one) as much as possible are included.
  533.     :s?pat?sub?
  534.         Substitute the first occurence of "pat" with "sub".  This
  535.         works like the |:s| command.  "pat" is a regular expression.
  536.         Any character can be used for '?', but it must not occur in
  537.         "pat" or "sub".
  538.         After this, the previous modifiers can be used again.  For
  539.         example ":p", to make a full path after the substitution.
  540.     :gs?pat?sub?
  541.         Substitute all occurences of "path" with "sub".  Otherwise
  542.         this works like ":s".
  543.  
  544. Examples, when the file name is "src/version.c", current dir "/home/mool/vim":
  545. >  :p            /home/mool/vim/src/version.c
  546. >  :p:.                       src/version.c
  547. >  :p:~                 ~/vim/src/version.c
  548. >  :h                       src
  549. >  :p:h            /home/mool/vim/src
  550. >  :p:h:h        /home/mool/vim
  551. >  :t                       version.c
  552. >  :p:t                       version.c
  553. >  :r                       src/version
  554. >  :p:r            /home/mool/vim/src/version
  555. >  :t:r                       version
  556. >  :e                           c
  557. >  :s?version?main?               src/main.c
  558. >  :s?version?main?:p    /home/mool/vim/src/main.c
  559. >  :p:gs?/?\\?        \home\mool\vim\src\version.c
  560.  
  561. Examples, when the file name is "src/version.c.gz":
  562. >  :p            /home/mool/vim/src/version.c.gz
  563. >  :e                             gz
  564. >  :e:e                           c.gz
  565. >  :e:e:e                       c.gz
  566. >  :e:e:r                       c
  567. >  :r                       src/version.c
  568. >  :r:e                           c
  569. >  :r:r                       src/version
  570. >  :r:r:r                   src/version
  571.  
  572.                     *extension-removal* *:_%<*
  573. If a "<" is appended to "%", "#", "#n" or "CTRL-V p" the extension of the file
  574. name is removed (everything after and including the last '.' in the file
  575. name).  This is included for backwards compatibility with version 3.0, the
  576. ":r" form is preferred.  Examples:
  577.  
  578. >    %        current file name
  579. >    %<        current file name without extension
  580. >    #        alternate file name for current window
  581. >    #<        idem, without extension
  582. >    #31        alternate file number 31
  583. >    #31<        idem, without extension
  584. >    <cword>        word under the cursor
  585. >    <cWORD>        WORD under the cursor (see |WORD|)
  586. >    <cfile>        path name under the cursor
  587. >    <cfile><    idem, without extension
  588.  
  589. Note: Where a file name is expected wildcards expansion is done.  On Unix the
  590. shell is used for this.  Backticks also work, like in
  591.     :n `echo *.c`
  592. But expansion is only done if there are any wildcards before expanding the
  593. '%', '#', etc..  This avoids expanding wildcards inside a file name.  If you
  594. want to expand the result of <cfile>, add a wildcard character to it.
  595. Examples: (alternate file name is "?readme?")
  596.     command        expands to  ~
  597.     :e #        :e ?readme?
  598.     :e `ls #`    :e {files matching "?readme?"}
  599.     :e #.*        :e {files matching "?readme?.*"}
  600.     :cd <cfile>    :cd {file name under cursor}
  601.     :cd <cfile>*    :cd {file name under cursor plus "*" and then expanded}
  602.  
  603.                             *filename-backslash*
  604. For filesystems that use a backslash as directory separator (MS-DOS, Windows,
  605. OS/2), it's a bit difficult to recognize a backslash that is used to escape
  606. the special meaning of the next character.  The general rule is: If the
  607. backslash is followed by a normal file name character, it does not have a
  608. special meaning.  Therefore "\file\foo" is a valid file name, you don't have
  609. to type the backslash twice.
  610.  
  611. And exception is the '$' sign.  It is a valid character in a file name.  But
  612. to avoid a file name like "$home" to be interpreted as an environment variable,
  613. it needs to be preceded by a backslash.  Therefore you need to use "/\$home"
  614. for the file "$home" in the root directory.  A few examples:
  615.  
  616.     FILE NAME    INTERPRETED AS    ~
  617.     $home        expanded to value of environment var $home
  618.     \$home        file "$home" in current directory
  619.     /\$home        file "$home" in root directory
  620.     \\$home        file "\\", followed by expanded $home
  621.  
  622.  vim:tw=78:ts=8:sw=8:
  623.