neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

cmdline.txt (55949B)


      1 *cmdline.txt*   Nvim
      2 
      3 
      4 	  VIM REFERENCE MANUAL	  by Bram Moolenaar
      5 
      6 
      7 			*Cmdline-mode* *Command-line-mode* *Cmdline*
      8 Command-line mode		*cmdline* *Command-line* *mode-cmdline* *:*
      9 
     10 Command-line mode is used to enter Ex commands (":"), search patterns
     11 ("/" and "?"), and filter commands ("!").
     12 
     13 Basic command line editing is explained in chapter 20 of the user manual
     14 |usr_20.txt|.
     15 
     16                                      Type |gO| to see the table of contents.
     17 
     18 ==============================================================================
     19 1. Command-line editing					*cmdline-editing*
     20 
     21 Normally characters are inserted in front of the cursor position.  You can
     22 move around in the command-line with the left and right cursor keys.  With the
     23 <Insert> key, you can toggle between inserting and overstriking characters.
     24 
     25 Note that if your keyboard does not have working cursor keys or any of the
     26 other special keys, you can use ":cnoremap" to define another key for them.
     27 For example, to define tcsh style editing keys:		*tcsh-style*  >
     28 :cnoremap <C-A> <Home>
     29 :cnoremap <C-F> <Right>
     30 :cnoremap <C-B> <Left>
     31 :cnoremap <Esc>b <S-Left>
     32 :cnoremap <Esc>f <S-Right>
     33 (<> notation |<>|; type all this literally)
     34 
     35 						*cmdline-too-long*
     36 When the command line is getting longer than what fits on the screen, only the
     37 part that fits will be shown.  The cursor can only move in this visible part,
     38 thus you cannot edit beyond that.
     39 
     40 					*cmdline-history* *history*
     41 The command-lines that you enter are remembered in a history table.  You can
     42 recall them with the up and down cursor keys.  There are actually five
     43 history tables:
     44 
     45 - one for ':' commands
     46 - one for search strings
     47 - one for expressions
     48 - one for input lines, typed for the |input()| function.
     49 - one for debug mode commands
     50 
     51 These are completely separate.  Each history can only be accessed when
     52 entering the same type of line.
     53 Use the 'history' option to set the number of lines that are remembered.
     54 
     55 Notes:
     56 
     57 - When you enter a command-line that is exactly the same as an older one, the
     58  old one is removed (to avoid repeated commands moving older commands out of
     59  the history).
     60 - Only commands that are typed are remembered.  A command executed completely
     61  from a mapping is not put in the history.
     62 - All searches are put in the search history, including the ones that come
     63  from commands like "*" and "#".  But for a mapping, only the last search is
     64  remembered (to avoid that long mappings trash the history).
     65 
     66 There is an automatic completion of names on the command-line; see
     67 |cmdline-completion|.
     68 
     69 						*c_CTRL-V*
     70 CTRL-V		Insert next non-digit literally.  Up to three digits form the
     71 	decimal value of a single byte.  The non-digit and the three
     72 	digits are not considered for mapping.  This works the same
     73 	way as in Insert mode (see above, |i_CTRL-V|).
     74 	For special keys, the CTRL modifier may be included into the
     75 	key to produce a control character.  If there is no control
     76 	character for the key then its |key-notation| is inserted.
     77 	Note: Under Windows CTRL-V is often mapped to paste text.
     78 	Use CTRL-Q instead then.
     79 						*c_CTRL-Q*
     80 CTRL-Q		Same as CTRL-V.  But with some terminals it is used for
     81 	control flow, it doesn't work then.
     82 
     83 CTRL-SHIFT-V				*c_CTRL-SHIFT-V* *c_CTRL-SHIFT-Q*
     84 CTRL-SHIFT-Q	Works just like CTRL-V, but do not try to include the CTRL
     85 	modifier into the key.
     86 	Note: When CTRL-SHIFT-V is intercepted by your system (e.g.,
     87 	to paste text) you can often use CTRL-SHIFT-Q instead.
     88 	However, in some terminals (e.g. GNOME Terminal), CTRL-SHIFT-Q
     89 	quits the terminal without confirmation.
     90 
     91 						*c_<Left>* *c_Left*
     92 <Left>		cursor left.  See 'wildmenu' for behavior during wildmenu
     93 	completion mode.
     94 						*c_<Right>* *c_Right*
     95 <Right>		cursor right.  See 'wildmenu' for behavior during wildmenu
     96 	completion mode.
     97 						*c_<S-Left>*
     98 <S-Left> or <C-Left>					*c_<C-Left>*
     99 	cursor one WORD left
    100 						*c_<S-Right>*
    101 <S-Right> or <C-Right>					*c_<C-Right>*
    102 	cursor one WORD right
    103 CTRL-B or <Home>				*c_CTRL-B* *c_<Home>* *c_Home*
    104 	cursor to beginning of command-line
    105 CTRL-E or <End>					*c_CTRL-E* *c_<End>* *c_End*
    106 	cursor to end of command-line.  See 'wildmenu' for behavior
    107 	during wildmenu completion mode.
    108 
    109 						*c_<LeftMouse>*
    110 <LeftMouse>	Move the cursor to the position of the mouse click.
    111 
    112 						*c_<MiddleMouse>*
    113 <MiddleMouse>	Paste the contents of the clipboard (for X11 the primary
    114 	selection).  This is similar to using `CTRL-R *`, but no CR
    115 	characters are inserted between lines.
    116 
    117 CTRL-H						*c_<BS>* *c_CTRL-H* *c_BS*
    118 <BS>		Delete the character in front of the cursor.
    119 						*c_<Del>* *c_Del*
    120 <Del>		Delete the character under the cursor (at end of line:
    121 	character before the cursor).
    122 						*c_CTRL-W*
    123 CTRL-W		Delete the |word| before the cursor.  This depends on the
    124 	'iskeyword' option.
    125 						*c_CTRL-U*
    126 CTRL-U		Remove all characters between the cursor position and
    127 	the beginning of the line.  Previous versions of vim
    128 	deleted all characters on the line.  If that is the
    129 	preferred behavior, add the following to your vimrc: >
    130 		:cnoremap <C-U> <C-E><C-U>
    131 <
    132 					*c_<Insert>* *c_Insert*
    133 <Insert>	Toggle between insert and overstrike.
    134 
    135 {char1} <BS> {char2}	or				*c_digraph*
    136 CTRL-K {char1} {char2}					*c_CTRL-K*
    137 	enter digraph (see |digraphs|).  When {char1} is a special
    138 	key, the code for that key is inserted in <> form.
    139 
    140 CTRL-R {register}					*c_CTRL-R* *c_<C-R>*
    141 	Insert the contents of a numbered or named register.  Between
    142 	typing CTRL-R and the second character '"' will be displayed
    143 	to indicate that you are expected to enter the name of a
    144 	register.
    145 	When used with named or clipboard registers (A-Z,a-z,0-9,+)
    146 	text is inserted literally like pasting with "p". For other
    147 	registers, the text is inserted as if you typed it, but
    148 	mappings and abbreviations are not used. Command-line
    149 	completion through 'wildchar' is not triggered though.  And
    150 	characters that end the command line are inserted literally
    151 	(<Esc>, <CR>, <NL>, <C-C>).  A <BS> or CTRL-W could still end
    152 	the command line though, and remaining characters will then be
    153 	interpreted in another mode, which might not be what you
    154 	intended.
    155 	Special registers:
    156 		'"'	the unnamed register, containing the text of
    157 			the last delete or yank
    158 		'%'	the current file name
    159 		'#'	the alternate file name
    160 		"*"	the clipboard contents (X11: primary
    161 			selection)
    162 		'+'	the clipboard contents
    163 		'/'	the last search pattern
    164 		':'	the last command-line
    165 		'-'	the last small (less than a line) delete
    166 		'.'	the last inserted text
    167 						*c_CTRL-R_=*
    168 		'='	the expression register: you are prompted to
    169 			enter an expression (see |expression|)
    170 			(doesn't work at the expression prompt; some
    171 			things such as changing the buffer or current
    172 			window are not allowed to avoid side effects)
    173 			When the result is a |List| the items are used
    174 			as lines.  They can have line breaks inside
    175 			too.
    176 			When the result is a Float it's automatically
    177 			converted to a String.
    178 			Note that when you only want to move the
    179 			cursor and not insert anything, you must make
    180 			sure the expression evaluates to an empty
    181 			string.  E.g.: >
    182 				<C-R><C-R>=setcmdpos(2)[-1]<CR>
    183 <				You can use this to insert a register as
    184 			typed with CTRL-R =@reg.
    185 	See |registers| about registers.
    186 	Implementation detail: When using the |expression| register
    187 	and invoking setcmdpos(), this sets the position before
    188 	inserting the resulting string.  Use CTRL-R CTRL-R to set the
    189 	position afterwards.
    190 
    191 CTRL-R CTRL-F				*c_CTRL-R_CTRL-F* *c_<C-R>_<C-F>*
    192 CTRL-R CTRL-P				*c_CTRL-R_CTRL-P* *c_<C-R>_<C-P>*
    193 CTRL-R CTRL-W				*c_CTRL-R_CTRL-W* *c_<C-R>_<C-W>*
    194 CTRL-R CTRL-A				*c_CTRL-R_CTRL-A* *c_<C-R>_<C-A>*
    195 CTRL-R CTRL-L				*c_CTRL-R_CTRL-L* *c_<C-R>_<C-L>*
    196 	Insert the object under the cursor:
    197 		CTRL-F	the Filename under the cursor
    198 		CTRL-P	the Filename under the cursor, expanded with
    199 			'path' as in |gf|
    200 		CTRL-W	the Word under the cursor
    201 		CTRL-A	the WORD under the cursor; see |WORD|
    202 		CTRL-L	the line under the cursor
    203 
    204 	When 'incsearch' is set the cursor position at the end of the
    205 	currently displayed match is used.  With CTRL-W the part of
    206 	the word that was already typed is not inserted again.
    207 
    208 				*c_CTRL-R_CTRL-R* *c_<C-R>_<C-R>*
    209 				*c_CTRL-R_CTRL-O* *c_<C-R>_<C-O>*
    210 CTRL-R CTRL-R `{register CTRL-F CTRL-P CTRL-W CTRL-A CTRL-L}`
    211 CTRL-R CTRL-O `{register CTRL-F CTRL-P CTRL-W CTRL-A CTRL-L}`
    212 	Insert register or object under the cursor.  Works like
    213 	|c_CTRL-R| but inserts the text literally.  For example, if
    214 	register a contains "xy^Hz" (where ^H is a backspace),
    215 	"CTRL-R a" will insert "xz" while "CTRL-R CTRL-R a" will
    216 	insert "xy^Hz".
    217 
    218 CTRL-\ e {expr}						*c_CTRL-\_e*
    219 	Evaluate {expr} and replace the whole command line with the
    220 	result.  You will be prompted for the expression, type <Enter>
    221 	to finish it.  It's most useful in mappings though.  See
    222 	|expression|.
    223 	See |c_CTRL-R_=| for inserting the result of an expression.
    224 	Useful functions are |getcmdtype()|, |getcmdline()| and
    225 	|getcmdpos()|.
    226 	The cursor position is unchanged, except when the cursor was
    227 	at the end of the line, then it stays at the end.
    228 	|setcmdpos()| can be used to set the cursor position.
    229 	The |sandbox| is used for evaluating the expression to avoid
    230 	nasty side effects.
    231 	Example: >
    232 		:cmap <F7> <C-\>eAppendSome()<CR>
    233 		:func AppendSome()
    234 		   :let cmd = getcmdline() .. " Some()"
    235 		   :" place the cursor on the )
    236 		   :call setcmdpos(strlen(cmd))
    237 		   :return cmd
    238 		:endfunc
    239 <		This doesn't work recursively, thus not when already editing
    240 	an expression.  But it is possible to use in a mapping.
    241 
    242 						*c_CTRL-Y*
    243 CTRL-Y		When there is a modeless selection, copy the selection into
    244 	the clipboard.
    245 	If there is no selection CTRL-Y is inserted as a character.
    246 	See 'wildmenu' for behavior during wildmenu completion mode.
    247 
    248 						*c_CTRL-Z*
    249 CTRL-Z		Trigger 'wildmode'. Same as 'wildcharm', but always available.
    250 
    251 CTRL-M or CTRL-J		*c_CTRL-M* *c_CTRL-J* *c_<NL>* *c_<CR>* *c_CR*
    252 <CR> or <NL>	start entered command
    253 
    254 CTRL-[						*c_CTRL-[* *c_<Esc>* *c_Esc*
    255 <Esc>		When typed and 'x' not present in 'cpoptions', quit
    256 	Command-line mode without executing.  In macros or when 'x'
    257 	present in 'cpoptions', start entered command.
    258 	Note: If your <Esc> key is hard to hit on your keyboard, train
    259 	yourself to use CTRL-[.
    260 					*c_META* *c_ALT*
    261 	ALT (|META|) may act like <Esc> if the chord is not mapped.
    262 	For example <A-x> acts like <Esc>x if <A-x> does not have a
    263 	command-line mode mapping.
    264 						*c_CTRL-C*
    265 CTRL-C		quit command-line without executing
    266 
    267 						*c_<Up>* *c_Up*
    268 <Up>		recall older command-line from history, whose beginning
    269 	matches the current command-line (see below).  See 'wildmenu'
    270 	for behavior during wildmenu completion mode.
    271 						*c_<Down>* *c_Down*
    272 <Down>		recall more recent command-line from history, whose beginning
    273 	matches the current command-line (see below).  See 'wildmenu'
    274 	for behavior during wildmenu completion mode.
    275 
    276 						*c_<S-Up>* *c_<PageUp>*
    277 <S-Up> or <PageUp>
    278 	recall older command-line from history
    279 					*c_<S-Down>* *c_<PageDown>*
    280 <S-Down> or <PageDown>
    281 	recall more recent command-line from history
    282 
    283 CTRL-D		command-line completion (see |cmdline-completion|)
    284 'wildchar' option
    285 	command-line completion (see |cmdline-completion|)
    286 CTRL-N		command-line completion (see |cmdline-completion|)
    287 CTRL-P		command-line completion (see |cmdline-completion|)
    288 CTRL-A		command-line completion (see |cmdline-completion|)
    289 CTRL-L		command-line completion (see |cmdline-completion|)
    290 
    291 						*c_CTRL-^*
    292 CTRL-^		Toggle the use of language |:lmap| mappings and/or Input
    293 	Method.
    294 	When typing a pattern for a search command and 'imsearch' is
    295 	not -1, VAL is the value of 'imsearch', otherwise VAL is the
    296 	value of 'iminsert'.
    297 	When language mappings are defined:
    298 	- If VAL is 1 (langmap mappings used) it becomes 0 (no langmap
    299 	  mappings used).
    300 	- If VAL was not 1 it becomes 1, thus langmap mappings are
    301 	  enabled.
    302 	When no language mappings are defined:
    303 	- If VAL is 2 (Input Method is used) it becomes 0 (no input
    304 	  method used)
    305 	- If VAL has another value it becomes 2, thus the Input Method
    306 	  is enabled.
    307 	These language mappings are normally used to type characters
    308 	that are different from what the keyboard produces.  The
    309 	'keymap' option can be used to install a whole number of them.
    310 	When entering a command line, langmap mappings are switched
    311 	off, since you are expected to type a command.  After
    312 	switching it on with CTRL-^, the new state is not used again
    313 	for the next command or Search pattern.
    314 
    315 					*c_CTRL-]*
    316 CTRL-]		Trigger abbreviation, without inserting a character.
    317 
    318 For Emacs-style editing on the command-line see |emacs-keys|.
    319 
    320 The <Up> and <Down> keys take the current command-line as a search string.
    321 The beginning of the next/previous command-lines are compared with this
    322 string.  The first line that matches is the new command-line.  When typing
    323 these two keys repeatedly, the same string is used again.  For example, this
    324 can be used to find the previous substitute command: Type ":s" and then <Up>.
    325 The same could be done by typing <S-Up> a number of times until the desired
    326 command-line is shown.  (Note: the shifted arrow keys do not work on all
    327 terminals)
    328 
    329 						*:his* *:history*
    330 :his[tory]	Print the history of last entered commands.
    331 
    332 :his[tory] [{name}] [{first}][, [{last}]]
    333 	List the contents of history {name} which can be:
    334 	c[md]	 or :		command-line history
    335 	s[earch] or / or ?	search string history
    336 	e[xpr]	 or =		expression register history
    337 	i[nput]	 or @		input line history
    338 	d[ebug]	 or >		debug command history
    339 	a[ll]			all of the above
    340 
    341 	If the numbers {first} and/or {last} are given, the respective
    342 	range of entries from a history is listed.  These numbers can
    343 	be specified in the following form:
    344 						*:history-indexing*
    345 	A positive number represents the absolute index of an entry
    346 	as it is given in the first column of a :history listing.
    347 	This number remains fixed even if other entries are deleted.
    348 	(see |E1510|)
    349 
    350 	A negative number means the relative position of an entry,
    351 	counted from the newest entry (which has index -1) backwards.
    352 
    353 	Examples:
    354 	List entries 6 to 12 from the search history: >
    355 		:history / 6,12
    356 <
    357 	List the penultimate entry from all histories: >
    358 		:history all -2
    359 <
    360 	List the most recent two entries from all histories: >
    361 		:history all -2,
    362 
    363 :keepp[atterns] {command}			*:keepp* *:keeppatterns*
    364 	Execute {command}, without adding anything to the search
    365 	history and, in case of |:s| or |:&|, without modifying the
    366 	last substitute pattern or substitute string.
    367 
    368 ==============================================================================
    369 2. Command-line completion				*cmdline-completion*
    370 
    371 When editing the command-line, a few commands can be used to complete the
    372 word before the cursor.  This is available for:
    373 
    374 - Command names: At the start of the command-line.
    375 - |++opt| values.
    376 - Tags: Only after the ":tag" command.
    377 - File names: Only after a command that accepts a file name or a setting for
    378  an option that can be set to a file name.  This is called file name
    379  completion.
    380 - Shell command names: After ":!cmd", ":r !cmd" and ":w !cmd".  $PATH is used.
    381 - Options: Only after the ":set" command.
    382 - Mappings: Only after a ":map" or similar command.
    383 - Variable and function names: Only after a ":if", ":call" or similar command.
    384 
    385 The number of help item matches is limited (currently to 300) to avoid a long
    386 delay when there are very many matches.
    387 
    388 For automatic completion as you type (without pressing a key like <Tab>),
    389 see |cmdline-autocompletion|.
    390 
    391 These are the commands that can be used:
    392 
    393 						*c_CTRL-D*
    394 CTRL-D		List names that match the pattern in front of the cursor.
    395 	When showing file names, directories are highlighted (see
    396 	|highlight-groups|).  Names where 'suffixes' matches are moved
    397 	to the end.
    398 	The 'wildoptions' option can be set to "tagfile" to list the
    399 	file of matching tags.
    400 			*c_CTRL-I* *c_wildchar* *c_<Tab>* */_<Tab>*
    401 'wildchar' option
    402 	A match is done on the pattern in front of the cursor.  The
    403 	match (if there are several, the first match) is inserted
    404 	in place of the pattern.  (Note: does not work inside a
    405 	macro, because <Tab> or <Esc> are mostly used as 'wildchar',
    406 	and these have a special meaning in some macros.) When typed
    407 	again and there were multiple matches, the next
    408 	match is inserted.  After the last match, the first is used
    409 	again (wrap around).
    410 
    411 	In search context use <CTRL-V><Tab> or "\t" to search for a
    412 	literal <Tab> instead of triggering completion.
    413 
    414 	The behavior can be changed with the 'wildmode' option.
    415 						*c_<S-Tab>*
    416 <S-Tab>		Like 'wildchar' or <Tab>, but begin with the last match and
    417 	then go to the previous match.
    418 						*c_CTRL-N*
    419 CTRL-N		After using 'wildchar' which got multiple matches, go to next
    420 	match.  Otherwise recall more recent command-line from
    421 	history.
    422 						*c_CTRL-P*
    423 CTRL-P		After using 'wildchar' which got multiple matches, go to
    424 	previous match.  Otherwise recall older command-line from
    425 	history.
    426 						*c_CTRL-A*
    427 CTRL-A		All names that match the pattern in front of the cursor are
    428 	inserted.
    429 						*c_CTRL-L*
    430 CTRL-L		A match is done on the pattern in front of the cursor.  If
    431 	there is one match, it is inserted in place of the pattern.
    432 	If there are multiple matches the longest common part is
    433 	inserted in place of the pattern.  If the result is shorter
    434 	than the pattern, no completion is done.
    435 						*/_CTRL-L*
    436 	When 'incsearch' is set, entering a search pattern for "/" or
    437 	"?" and the current match is displayed then CTRL-L will add
    438 	one character from the end of the current match.  If
    439 	'ignorecase' and 'smartcase' are set and the command line has
    440 	no uppercase characters, the added character is converted to
    441 	lowercase.
    442                                             *c_CTRL-G* */_CTRL-G*
    443 CTRL-G		When 'incsearch' is set, entering a search pattern for "/" or
    444 	"?" and the current match is displayed then CTRL-G will move
    445 	to the next match (does not take |search-offset| into account)
    446 	Use CTRL-T to move to the previous match.  Hint: on a regular
    447 	keyboard G is below T.
    448                                             *c_CTRL-T* */_CTRL-T*
    449 CTRL-T		When 'incsearch' is set, entering a search pattern for "/" or
    450 	"?" and the current match is displayed then CTRL-T will move
    451 	to the previous match (does not take |search-offset| into
    452 	account).
    453 	Use CTRL-G to move to the next match.  Hint: on a regular
    454 	keyboard T is above G.
    455 
    456 The 'wildchar' option defaults to <Tab> (CTRL-E when in Vi compatible mode; in
    457 a previous version <Esc> was used).  In the pattern standard |wildcards| are
    458 accepted when matching file names.
    459 
    460 When repeating 'wildchar' or CTRL-N you cycle through the matches, eventually
    461 ending up back to what was typed.  If the first match is not what you wanted,
    462 you can use <S-Tab> or CTRL-P to go straight back to what you typed.
    463 
    464 The 'wildmenu' option can be set to show the matches just above the command
    465 line.
    466 
    467 The 'wildoptions' option provides additional configuration to use a popup menu
    468 for 'wildmenu', and to use fuzzy matching.
    469 
    470 The 'wildignorecase' option can be set to ignore case in filenames.  For
    471 completing other texts (e.g. command names), the 'ignorecase' option is used
    472 instead (fuzzy matching always ignores case, however).
    473 
    474 If you like tcsh's autolist completion, you can use this mapping: >
    475 :cnoremap X <C-L><C-D>
    476 (Where X is the command key to use, <C-L> is CTRL-L and <C-D> is CTRL-D)
    477 This will find the longest match and then list all matching files.
    478 
    479 If you like tcsh's autolist completion, you can use the 'wildmode' option to
    480 emulate it.  For example, this mimics autolist=ambiguous: >
    481 :set wildmode=longest,list
    482 This will find the longest match with the first 'wildchar', then list all
    483 matching files with the next.
    484 
    485 				*complete-script-local-functions*
    486 When completing user function names, prepend "s:" to find script-local
    487 functions.
    488 
    489 						*suffixes*
    490 For file name completion you can use the 'suffixes' option to set a priority
    491 between files with almost the same name.  If there are multiple matches,
    492 those files with an extension that is in the 'suffixes' option are ignored.
    493 The default is ".bak,~,.o,.h,.info,.swp,.obj", which means that files ending
    494 in ".bak", "~", ".o", ".h", ".info", ".swp" and ".obj" are sometimes ignored.
    495 
    496 An empty entry, two consecutive commas, match a file name that does not
    497 contain a ".", thus has no suffix.  This is useful to ignore "prog" and prefer
    498 "prog.c".
    499 
    500 Examples:
    501 
    502  pattern:	files:				match:	~
    503   test*	test.c test.h test.o		test.c
    504   test*	test.h test.o			test.h and test.o
    505   test*	test.i test.h test.c		test.i and test.c
    506 
    507 It is impossible to ignore suffixes with two dots.
    508 
    509 If there is more than one matching file (after ignoring the ones matching
    510 the 'suffixes' option) the first file name is inserted.  You can see that
    511 there is only one match when you type 'wildchar' twice and the completed
    512 match stays the same.  You can get to the other matches by entering
    513 'wildchar', CTRL-N or CTRL-P.  All files are included, also the ones with
    514 extensions matching the 'suffixes' option.
    515 
    516 To completely ignore files with some extension use 'wildignore'.
    517 
    518 To match only files that end at the end of the typed text append a "$".  For
    519 example, to match only files that end in ".c": >
    520 :e *.c$
    521 This will not match a file ending in ".cpp".  Without the "$" it does match.
    522 
    523 If you would like using <S-Tab> for CTRL-P in an xterm, put this command in
    524 your .cshrc: >
    525 xmodmap -e "keysym Tab = Tab Find"
    526 And this in your vimrc: >
    527 :cmap <Esc>[1~ <C-P>
    528 <						*complete-set-option*
    529 When setting an option using |:set=|, the old value of an option can be
    530 obtained by hitting 'wildchar' just after the '='.  For example, typing
    531 'wildchar' after ":set dir=" will insert the current value of 'dir'.  This
    532 overrules file name completion for the options that take a file name.
    533 
    534 When using |:set=|, |:set+=|, or |:set^=|, string options that have
    535 pre-defined names or syntax (e.g. 'diffopt', 'listchars') or are a list of
    536 single-character flags (e.g. 'shortmess') will also present a list of possible
    537 values for completion when using 'wildchar'.
    538 
    539 When using |:set-=|, comma-separated options like 'diffopt' or 'backupdir'
    540 will show each item separately.  Flag list options like 'shortmess' will show
    541 both the entire old value and the individual flags.  Otherwise completion will
    542 just fill in with the entire old value.
    543 
    544 ==============================================================================
    545 3. Ex command-lines					*cmdline-lines*
    546 
    547 The Ex commands have a few specialties:
    548 
    549 						*:quote* *:comment*
    550 '"' at the start of a line causes the whole line to be ignored.  '"'
    551 after a command causes the rest of the line to be ignored.  This can be used
    552 to add comments.  Example: >
    553 :set ai		"set 'autoindent' option
    554 It is not possible to add a comment to a shell command ":!cmd" or to the
    555 ":map" command and a few others (mainly commands that expect expressions)
    556 that see the '"' as part of their argument:
    557 
    558    :argdo
    559    :autocmd
    560    :bufdo
    561    :cexpr (and the like)
    562    :cdo (and the like)
    563    :command
    564    :debug
    565    :display
    566    :echo (and the like)
    567    :elseif
    568    :execute
    569    :folddoopen
    570    :folddoclosed
    571    :for
    572    :grep (and the like)
    573    :help (and the like)
    574    :if
    575    :let
    576    :make
    577    :map (and the like including :abbrev commands)
    578    :menu (and the like)
    579    :mkspell
    580    :normal
    581    :popup
    582    :registers
    583    :return
    584    :sort
    585    :syntax
    586    :tabdo
    587    :tearoff
    588    :vimgrep (and the like)
    589    :while
    590    :windo
    591 
    592 						*:bar* *:\bar*
    593 '|' can be used to separate commands, so you can give multiple commands in one
    594 line.  If you want to use '|' in an argument, precede it with '\'.
    595 
    596 These commands see the '|' as their argument, and can therefore not be
    597 followed by another Vim command:
    598    :argdo
    599    :autocmd
    600    :bufdo
    601    :cdo
    602    :cfdo
    603    :command
    604    :debug
    605    :eval
    606    :folddoopen
    607    :folddoclosed
    608    :function
    609    :global
    610    :help
    611    :helpgrep
    612    :ldo
    613    :lfdo
    614    :lhelpgrep
    615    :make
    616    :normal
    617    :perlfile
    618    :pyfile
    619    :python
    620    :registers
    621    :read !
    622    :sign
    623    :tabdo
    624    :terminal
    625    :vglobal
    626    :windo
    627    :write !
    628    :[range]!
    629    a user defined command without the "-bar" argument |:command|
    630 
    631 Note that this is confusing (inherited from Vi): With ":g" the '|' is included
    632 in the command, with ":s" it is not.
    633 
    634 To be able to use another command anyway, use the ":execute" command.
    635 Example (append the output of "ls" and jump to the first line): >
    636 :execute 'r !ls' | '[
    637 
    638 There is one exception: When the 'b' flag is present in 'cpoptions', with the
    639 ":map" and ":abbr" commands and friends CTRL-V needs to be used instead of
    640 '\'.  You can also use "<Bar>" instead.  See also |map_bar|.
    641 
    642 Examples: >
    643 :!ls | wc		view the output of two commands
    644 :r !ls | wc		insert the same output in the text
    645 :%g/foo/p|>		moves all matching lines one shiftwidth
    646 :%s/foo/bar/|>		moves one line one shiftwidth
    647 :map q 10^V|		map "q" to "10|"
    648 :map q 10\| map \ l	map "q" to "10\" and map "\" to "l"
    649 				(when 'b' is present in 'cpoptions')
    650 
    651 You can also use <NL> to separate commands in the same way as with '|'.  To
    652 insert a <NL> use CTRL-V CTRL-J.  "^@" will be shown.  Using '|' is the
    653 preferred method.  But for external commands a <NL> must be used, because a
    654 '|' is included in the external command.  To avoid the special meaning of <NL>
    655 it must be preceded with a backslash.  Example: >
    656 :r !date<NL>-join
    657 This reads the current date into the file and joins it with the previous line.
    658 
    659 Note that when the command before the '|' generates an error, the following
    660 commands will not be executed.
    661 
    662 
    663 Because of Vi compatibility the following strange commands are supported: >
    664 :|			print current line (like ":p")
    665 :3|			print line 3 (like ":3p")
    666 :3			goto line 3
    667 
    668 A colon is allowed between the range and the command name.  It is ignored
    669 (this is Vi compatible).  For example: >
    670 :1,$:s/pat/string
    671 
    672 When the character '%' or '#' is used where a file name is expected, they are
    673 expanded to the current and alternate file name (see the chapter "editing
    674 files" |:_%| |:_#|).
    675 
    676 Trailing spaces in filenames will be ignored, unless escaped with a backslash
    677 or CTRL-V.  Note that the ":next" command uses spaces to separate file names.
    678 Escape the spaces to include them in a file name.  Example: >
    679 :next foo\ bar goes\ to school\
    680 starts editing the three files "foo bar", "goes to" and "school ".
    681 
    682 When you want to use the special characters '"' or '|' in a command, or want
    683 to use '%' or '#' in a file name, precede them with a backslash.  The
    684 backslash is not required in a range and in the ":substitute" command.
    685 See also |`=|.
    686 
    687 						*:_!*
    688 The '!' (bang) character after an Ex command makes the command behave in a
    689 different way.  The '!' should be placed immediately after the command,
    690 without any blanks in between.  If you insert blanks the '!' will be seen as
    691 an argument for the command, which has a different meaning.  For example:
    692 :w! name	write the current buffer to file "name", overwriting
    693 		any existing file
    694 :w !name	send the current buffer as standard input to command
    695 		"name"
    696 
    697 ==============================================================================
    698 4. Ex command-line ranges	*cmdline-ranges* *[range]* *E16*
    699 
    700 Some Ex commands accept a line range in front of them.  This is noted as
    701 [range].  It consists of one or more line specifiers, separated with ',' or
    702 ';'.
    703 
    704 The basics are explained in section |10.3| of the user manual.
    705 
    706 							*:,* *:;*
    707 When separated with ';' the cursor position will be set to that line
    708 before interpreting the next line specifier.  This doesn't happen for ','.
    709 Examples: >
    710   4,/this line/
    711 <	from line 4 till match with "this line" after the cursor line. >
    712   5;/that line/
    713 <	from line 5 till match with "that line" after line 5.
    714 
    715 The default line specifier for most commands is the cursor position, but the
    716 commands ":write" and ":global" have the whole buffer (1,$) as default.
    717 
    718 If more line specifiers are given than required for the command, when comma
    719 separated, the leftmost one(s) will be ignored, e.g., the -2,+ in this: >
    720 :-2,+,-2,. print
    721 <When semicolon separated, the leftmost specifier to the penultimate one are
    722 summed, e.g., -4 + 3 - 1 = -2, in this: >
    723 :-4;+3;-1;+2 print
    724 <
    725 Line numbers may be specified with:		*:range* *{address}*
    726 {number}	an absolute line number  *E1247*
    727 .		the current line			   *:.*
    728 $		the last line of the buffer		   *:$*
    729 %		equal to 1,$ (the entire buffer)	   *:%*
    730 *		equal to '<,'> (the lines of the last
    731 		selected Visual area; see |:star| below)
    732 'x		the line of the position of mark x	   *:'x*
    733 		(where x is any {a-z} mark)
    734 'X		the line of the position of mark X	   *:'X*
    735 		(where X is any {A-Z0-9} mark, though
    736 		when X is in another buffer it cannot
    737 		be used in a range)
    738 '[		the first line of the most recent	   *:'[*
    739 		change or yank
    740 ']		the last line of the most recent	   *:']*
    741 		change or yank
    742 '<		the first line of the most recently	   *:'<*
    743 		selected Visual area
    744 '>		the last line of the most recently	   *:'>*
    745 		selected Visual area
    746 ''		the line of the position before the	   *:''*
    747 		latest jump, or where the last "m'"/"m`"
    748 		command was given (though '' is 1 if it
    749 		isn't in the current buffer)
    750 '"		the line of the cursor position when	   *:'quote*
    751 		last exiting the buffer
    752 '^		the line of the cursor position the	   *:'^*
    753 		last time Insert mode was stopped
    754 '.		the line of the cursor position when the   *:'.*
    755 		buffer was last changed
    756 '(		the line of the first character of the	   *:'(*
    757 		current sentence
    758 ')		the line of the first character after	   *:')*
    759 		the end of the current sentence
    760 '{		the first empty line before the		   *:'{*
    761 		paragraph containing the cursor
    762 '}		the first empty line after the		   *:'}*
    763 		paragraph containing the cursor
    764 /{pattern}[/]	the next line where {pattern} matches	   *:/*
    765 			also see |:range-pattern| below
    766 ?{pattern}[?]	the previous line where {pattern} matches  *:?*
    767 			also see |:range-pattern| below
    768 \/		the next line where the most recent
    769 		search pattern matches
    770 \?		the previous line where the most recent
    771 		search pattern matches
    772 \&		the next line where the most recent
    773 		substitute pattern matches
    774 
    775 Note: "next line" and "previous line" do not include matches appearing
    776 in the current line.
    777 
    778 					*:range-offset*
    779 Each line specifier may be followed by one or more '+' or '-' and an optional
    780 number.  That value is added or subtracted from the preceding line number.
    781 So, for example, 'x+2 is two lines after the line containing mark x.  If the
    782 number is omitted, +1 is used for each '+' and -1 for each '-' so, e.g., 'x++
    783 and 'x+2 are synonymous.  If there is nothing before the '+' or '-', for the
    784 first line number in [range] the current line is used as the relative
    785 starting point.  So, -,. means, "the line before the current line to the
    786 current line".  The value of the second line number in [range] depends on
    787 whether a comma or semicolon separates the line numbers (see |:,| and |:;|).
    788 Examples: If the cursor is within the line below this one, any of these
    789 commands will print the tag line ":range-offset" and the line, "Each...": >
    790 :-11;+1 print
    791 :-----------,-10 print
    792 :?Each line?-;+ print
    793 :'{+,'{+2 print
    794 :'{+1;')-1 print
    795 <						*:range-closed-fold*
    796 When a line number after the comma is in a closed fold it is adjusted to the
    797 last line of the fold, thus the whole fold is included.
    798 
    799 When a number is added this is done after the adjustment to the last line of
    800 the fold.  This means these lines are additionally included in the range.  For
    801 example: >
    802   :3,4+2print
    803 On this text:
    804 1 one ~
    805 2 two ~
    806 3 three ~
    807 4 four FOLDED ~
    808 5 five FOLDED ~
    809 6 six ~
    810 7 seven ~
    811 8 eight ~
    812 Where lines four and five are a closed fold, ends up printing lines 3 to 7.
    813 The 7 comes from the "4" in the range, which is adjusted to the end of the
    814 closed fold, which is 5, and then the offset 2 is added.
    815 
    816 An example for subtracting (which isn't very useful): >
    817   :2,4-1print
    818 On this text:
    819 1 one ~
    820 2 two ~
    821 3 three FOLDED ~
    822 4 four FOLDED ~
    823 5 five FOLDED ~
    824 6 six FOLDED ~
    825 7 seven ~
    826 8 eight ~
    827 Where lines three to six are a closed fold, ends up printing lines 2 to 6.
    828 The 6 comes from the "4" in the range, which is adjusted to the end of the
    829 closed fold, which is 6, and then 1 is subtracted, then this is still in the
    830 closed fold and the last line of that fold is used, which is 6.
    831 
    832 						*:range-pattern*
    833 The "/" and "?" after {pattern} are required to separate the pattern from
    834 anything that follows.
    835 
    836 The "/" and "?" may be preceded with another address.  The search starts from
    837 there.  The difference from using ';' is that the cursor isn't moved.
    838 Examples: >
    839 /pat1//pat2/	Find line containing "pat2" after line containing
    840 		"pat1", without moving the cursor.
    841 7;/pat2/	Find line containing "pat2", after line 7, leaving
    842 		the cursor in line 7.
    843 
    844 The {number} must be between 0 and the number of lines in the file.  When
    845 using a 0 (zero) this is interpreted as a 1 by most commands.  Commands that
    846 use it as a count do use it as a zero (|:tag|, |:pop|, etc).  Some commands
    847 interpret the zero as "before the first line" (|:read|, search pattern, etc).
    848 
    849 Examples: >
    850 .+3		three lines below the cursor
    851 /that/+1	the line below the next line containing "that"
    852 .,$		from current line until end of file
    853 0;/that		the first line containing "that", also matches in the
    854 		first line.
    855 1;/that		the first line after line 1 containing "that"
    856 
    857 Some commands allow for a count after the command.  This count is used as the
    858 number of lines to be used, starting with the line given in the last line
    859 specifier (the default is the cursor line).  The commands that accept a count
    860 are the ones that use a range but do not have a file name argument (because
    861 a file name can also be a number).  The count cannot be negative.
    862 
    863 Examples: >
    864 :s/x/X/g 5	substitute 'x' by 'X' in the current line and four
    865 		following lines
    866 :23d 4		delete lines 23, 24, 25 and 26
    867 
    868 
    869 Folds and Range
    870 
    871 When folds are active the line numbers are rounded off to include the whole
    872 closed fold.  See |fold-behavior|.
    873 
    874 
    875 Reverse Range						*E493*
    876 
    877 A range should have the lower line number first.  If this is not the case, Vim
    878 will ask you if it should swap the line numbers.
    879 Backwards range given, OK to swap ~
    880 This is not done within the global command ":g".
    881 
    882 You can use ":silent" before a command to avoid the question, the range will
    883 always be swapped then.
    884 
    885 
    886 Count and Range						*N:*
    887 
    888 When giving a count before entering ":", this is translated into: >
    889 	:.,.+(count - 1)
    890 In words: The "count" lines at and after the cursor.  Example: To delete
    891 three lines: >
    892 	3:d<CR>		is translated into: .,.+2d<CR>
    893 <
    894 
    895 Visual Mode and Range
    896 						*v_:*
    897 {Visual}:	Starts a command-line with the Visual selected lines as a
    898 	range.  The code `:'<,'>` is used for this range, which makes
    899 	it possible to select a similar line from the command-line
    900 	history for repeating a command on different Visually selected
    901 	lines.
    902 
    903 :*						*:star* *:star-visual-range*
    904 	When Visual mode was already ended, a short way to use the
    905 	Visual area for a range is `:*`.
    906 
    907 ==============================================================================
    908 5. Ex command-line flags				*ex-flags*
    909 
    910 These flags are supported by a selection of Ex commands.  They print the line
    911 that the cursor ends up after executing the command:
    912 
    913 l	output like for |:list|
    914 #	add line number
    915 p	output like for |:print|
    916 
    917 The flags can be combined, thus "l#" uses both a line number and |:list| style
    918 output.
    919 
    920 ==============================================================================
    921 6. Ex special characters				*cmdline-special*
    922 
    923 Note: These are special characters in the executed command line.  If you want
    924 to insert special things while typing you can use the CTRL-R command.  For
    925 example, "%" stands for the current file name, while CTRL-R % inserts the
    926 current file name right away.  See |c_CTRL-R|.
    927 
    928 Note: If you want to avoid the effects of special characters in a Vim script
    929 you may want to use |fnameescape()|.  Also see |`=|.
    930 
    931 
    932 In Ex commands, at places where a file name can be used, the following
    933 characters have a special meaning.  These can also be used in the expression
    934 function |expand()|.
    935 %	Is replaced with the current file name.		  *:_%* *c_%*
    936 #	Is replaced with the alternate file name.	  *:_#* *c_#*
    937 	This is remembered for every window.
    938 #n	(where n is a number) is replaced with		  *:_#0* *:_#n*
    939 	the file name of buffer n.  "#0" is the same as "#".     *c_#n*
    940 ##	Is replaced with all names in the argument list	  *:_##* *c_##*
    941 	concatenated, separated by spaces.  Each space in a name
    942 	is preceded with a backslash.
    943 #<n	(where n is a number > 0) is replaced with old	  *:_#<* *c_#<*
    944 	file name n.  See |:oldfiles| or |v:oldfiles| to get the
    945 	number.							*E809*
    946 
    947 Note that these, except "#<n", give the file name as it was typed.  If an
    948 absolute path is needed (when using the file name from a different directory),
    949 you need to add ":p".  See |filename-modifiers|.
    950 
    951 The "#<n" item returns an absolute path, but it will start with "~/" for files
    952 below your home directory.
    953 
    954 Note that backslashes are inserted before spaces, so that the command will
    955 correctly interpret the file name.  But this doesn't happen for shell
    956 commands.  For those you probably have to use quotes (this fails for files
    957 that contain a quote and wildcards): >
    958 :!ls "%"
    959 :r !spell "%"
    960 
    961 To avoid the special meaning of '%' and '#' insert a backslash before it.
    962 Detail: The special meaning is always escaped when there is a backslash before
    963 it, no matter how many backslashes.
    964 you type:		result	~
    965    #			alternate.file
    966    \#			#
    967    \\#			\#
    968 Also see |`=|.
    969 
    970 						*E499* *E500*
    971 Note: these are typed literally, they are not special keys!
    972 						*:<cword>* *<cword>*
    973 <cword>    is replaced with the word under the cursor (like |star|)
    974 						*:<cWORD>* *<cWORD>*
    975 <cWORD>    is replaced with the WORD under the cursor (see |WORD|)
    976 						*:<cexpr>* *<cexpr>*
    977 <cexpr>    is replaced with the word under the cursor, including more
    978 	   to form a C expression.  E.g., when the cursor is on "arg"
    979 	   of "ptr->arg" then the result is "ptr->arg"; when the
    980 	   cursor is on "]" of "list[idx]" then the result is
    981 	   "list[idx]".
    982 						*:<cfile>* *<cfile>*
    983 <cfile>    is replaced with the path name under the cursor (like what
    984 	   |gf| uses)
    985 						*:<afile>* *<afile>*
    986 <afile>    When executing autocommands, is replaced with the file name
    987 	   of the buffer being manipulated, or the file for a read or
    988 	   write.  *E495*
    989 						*:<abuf>* *<abuf>*
    990 <abuf>     When executing autocommands, is replaced with the currently
    991 	   effective buffer number.  It is not set for all events,
    992 	   also see |bufnr()|.  For ":r file" and ":so file" it is the
    993 	   current buffer, the file being read/sourced is not in a
    994 	   buffer.  *E496*
    995 						*:<amatch>* *<amatch>*
    996 <amatch>   When executing autocommands, is replaced with the match for
    997 	   which this autocommand was executed.  *E497*
    998 	   It differs from <afile> when the file name isn't used to
    999 	   match with (for FileType, Syntax and SpellFileMissing
   1000 	   events).
   1001 	   When the match is with a file name, it is expanded to the
   1002 	   full path.
   1003 						*:<stack>* *<stack>*
   1004 <stack>	   is replaced with the call stack, using
   1005 	   "function {function-name}[{lnum}]" for a function line
   1006 	   and "script {file-name}[{lnum}]" for a script line, and
   1007 	   ".." in between items.  E.g.:
   1008 	   "function {function-name1}[{lnum}]..{function-name2}[{lnum}]"
   1009 	   If there is no call stack you get error *E489* .
   1010 						*:<script>* *<script>* *E498*
   1011 <script>   When executing a `:source` command, is replaced with the file
   1012 	   name of the sourced file.  When executing a function, is
   1013 	   replaced with the file name of the script where it is
   1014 	   defined.
   1015 	   If the file name cannot be determined you get error *E1274* .
   1016 						*:<slnum>* *<slnum>*
   1017 <slnum>	   When executing a `:source` command, is replaced with the
   1018 	   line number.  *E842*
   1019 	   When executing a function it's the line number relative to
   1020 	   the start of the function.
   1021 						*:<sflnum>* *<sflnum>*
   1022 <sflnum>   When executing a script, is replaced with the line number.
   1023 	   It differs from <slnum> in that <sflnum> is replaced with
   1024 	   the script line number in any situation.  *E961*
   1025 
   1026 						 *filename-modifiers*
   1027 *:_%:* *::8* *::p* *::.* *::~* *::h* *::t* *::r* *::e* *::s* *::gs* *::S*
   1028     *%:8* *%:p* *%:.* *%:~* *%:h* *%:t* *%:r* *%:e* *%:s* *%:gs* *%:S*
   1029 The file name modifiers can be used after "%", "#", "#n", "<cfile>",
   1030 "<script>", "<afile>" or "<abuf>".  They are also used with the |fnamemodify()|
   1031 function.
   1032 
   1033 These modifiers can be given, in this order:
   1034 :p	Make file name a full path.  Must be the first modifier.  Also
   1035 	changes "~/" (and "~user/" for Unix) to the path for the home
   1036 	directory.  If the name is a directory a path separator is
   1037 	added at the end.  For a file name that does not exist and
   1038 	does not have an absolute path the result is unpredictable.
   1039 	On MS-Windows an 8.3 filename is expanded to the long name.
   1040 :8	Converts the path to 8.3 short format (currently only on
   1041 	MS-Windows).  Will act on as much of a path that is an
   1042 	existing path.
   1043 :~	Reduce file name to be relative to the home directory, if
   1044 	possible.  File name is unmodified if it is not below the home
   1045 	directory.
   1046 :.	Reduce file name to be relative to current directory, if
   1047 	possible.  File name is unmodified if it is not below the
   1048 	current directory.
   1049 	For maximum shortness, use ":~:.".
   1050 :h	Head of the file name (the last component and any separators
   1051 	removed).  Cannot be used with :e, :r or :t.
   1052 	Can be repeated to remove several components at the end.
   1053 	When the file name ends in a path separator, only the path
   1054 	separator is removed.  Thus ":p:h" on a directory name results
   1055 	on the directory name itself (without trailing slash).
   1056 	When the file name is an absolute path (starts with "/" for
   1057 	Unix; "x:\" for Win32), that part is not removed.
   1058 	When there is no head (path is relative to current directory)
   1059 	the result is empty.
   1060 :t	Tail of the file name (last component of the name).  Must
   1061 	precede any :r or :e.
   1062 :r	Root of the file name (the last extension removed).  When
   1063 	there is only an extension (file name that starts with '.',
   1064 	e.g., ".nvimrc"), it is not removed.  Can be repeated to
   1065 	remove several extensions (last one first).
   1066 :e	Extension of the file name.  Only makes sense when used alone.
   1067 	When there is no extension the result is empty.
   1068 	When there is only an extension (file name that starts with
   1069 	'.'), the result is empty.  Can be repeated to include more
   1070 	extensions.  If there are not enough extensions (but at least
   1071 	one) as much as possible are included.
   1072 :s?pat?sub?
   1073 	Substitute the first occurrence of "pat" with "sub".  This
   1074 	works like the |:s| command.  "pat" is a regular expression.
   1075 	Any character can be used for '?', but it must not occur in
   1076 	"pat" or "sub".
   1077 	After this, the previous modifiers can be used again.  For
   1078 	example ":p", to make a full path after the substitution.
   1079 :gs?pat?sub?
   1080 	Substitute all occurrences of "pat" with "sub".  Otherwise
   1081 	this works like ":s".
   1082 :S	Escape special characters for use with a shell command (see
   1083 	|shellescape()|).  Must be the last one.  Examples: >
   1084 	    :!dir <cfile>:S
   1085 	    :call system('chmod +w -- ' .. expand('%:S'))
   1086 
   1087 Examples, when the file name is "src/version.c", current dir
   1088 "/home/mool/vim": >
   1089  :p			/home/mool/vim/src/version.c
   1090  :p:.				       src/version.c
   1091  :p:~				 ~/vim/src/version.c
   1092  :h				       src
   1093  :p:h			/home/mool/vim/src
   1094  :p:h:h		/home/mool/vim
   1095  :t					   version.c
   1096  :p:t					   version.c
   1097  :r				       src/version
   1098  :p:r			/home/mool/vim/src/version
   1099  :t:r					   version
   1100  :e						   c
   1101  :s?version?main?		       src/main.c
   1102  :s?version?main?:p	/home/mool/vim/src/main.c
   1103  :p:gs?/?\\?		\home\mool\vim\src\version.c
   1104 
   1105 Examples, when the file name is "src/version.c.gz": >
   1106  :p			/home/mool/vim/src/version.c.gz
   1107  :e						     gz
   1108  :e:e						   c.gz
   1109  :e:e:e					   c.gz
   1110  :e:e:r					   c
   1111  :r				       src/version.c
   1112  :r:e						   c
   1113  :r:r				       src/version
   1114  :r:r:r			       src/version
   1115 <
   1116 				*extension-removal* *:_%<*
   1117 If a "<" is appended to "%", "#", "#n" or "CTRL-V p" the extension of the file
   1118 name is removed (everything after and including the last '.' in the file
   1119 name).  This is included for backwards compatibility with version 3.0, the
   1120 ":r" form is preferred.  Examples: >
   1121 
   1122 %		current file name
   1123 %<		current file name without extension
   1124 #		alternate file name for current window
   1125 #<		idem, without extension
   1126 #31		alternate file number 31
   1127 #31<		idem, without extension
   1128 <cword>		word under the cursor
   1129 <cWORD>		WORD under the cursor (see |WORD|)
   1130 <cfile>		path name under the cursor
   1131 <cfile><	idem, without extension
   1132 
   1133 Note: Where a file name is expected wildcards expansion is done.  On Unix the
   1134 shell is used for this, unless it can be done internally (for speed).
   1135 Backticks work also, like in >
   1136 :n `echo *.c`
   1137 But expansion is only done if there are any wildcards before expanding the
   1138 '%', '#', etc..  This avoids expanding wildcards inside a file name.  If you
   1139 want to expand the result of <cfile>, add a wildcard character to it.
   1140 Examples: (alternate file name is "?readme?")
   1141 command		expands to >
   1142 :e #		:e ?readme?
   1143 :e `ls #`	:e {files matching "?readme?"}
   1144 :e #.*		:e {files matching "?readme?.*"}
   1145 :cd <cfile>	:cd {file name under cursor}
   1146 :cd <cfile>*	:cd {file name under cursor plus "*" and then expanded}
   1147 Also see |`=|.
   1148 
   1149 When the expanded argument contains a "!" and it is used for a shell command
   1150 (":!cmd", ":r !cmd" or ":w !cmd"), the "!" is escaped with a backslash to
   1151 avoid it being expanded into a previously used command.  When the 'shell'
   1152 option contains "sh", this is done twice, to avoid the shell trying to expand
   1153 the "!".
   1154 
   1155 						*filename-backslash*
   1156 For filesystems that use a backslash as directory separator (Windows
   1157 filesystems), it's a bit difficult to recognize a backslash that is used
   1158 to escape the special meaning of the next character.  The general rule is: If
   1159 the backslash is followed by a normal file name character, it does not have a
   1160 special meaning.  Therefore "\file\foo" is a valid file name, you don't have
   1161 to type the backslash twice.
   1162 
   1163 An exception is the '$' sign.  It is a valid character in a file name.  But
   1164 to avoid a file name like "$home" to be interpreted as an environment
   1165 variable, it needs to be preceded by a backslash.  Therefore you need to use
   1166 "/\$home" for the file "$home" in the root directory.  A few examples:
   1167 
   1168 FILE NAME	INTERPRETED AS	~
   1169 $home		expanded to value of environment var $home
   1170 \$home		file "$home" in current directory
   1171 /\$home		file "$home" in root directory
   1172 \\$home		file "\\", followed by expanded $home
   1173 
   1174 Also see |`=|.
   1175 
   1176 ==============================================================================
   1177 7. Command-line window				*cmdline-window* *cmdwin*
   1178 						*command-line-window*
   1179 In the command-line window the command line can be edited just like editing
   1180 text in any window.  It is a special kind of window, because you cannot leave
   1181 it in a normal way.
   1182 
   1183 
   1184 OPEN						*c_CTRL-F* *q:* *q/* *q?*
   1185 
   1186 There are two ways to open the command-line window:
   1187 1. From Command-line mode, use the key specified with the 'cedit' option.
   1188 2. From Normal mode, use the "q:", "q/" or "q?" command.
   1189   This starts editing an Ex command-line ("q:") or search string ("q/" or
   1190   "q?").  Note that this is not possible while recording is in progress (the
   1191   "q" stops recording then).
   1192 
   1193 When the window opens it is filled with the command-line history.  The last
   1194 line contains the command as typed so far.  The left column will show a
   1195 character that indicates the type of command-line being edited, see
   1196 |cmdwin-char|.
   1197 
   1198 Vim will be in Normal mode when the editor is opened.
   1199 
   1200 The height of the window is specified with 'cmdwinheight' (or smaller if there
   1201 is no room).  The window is always full width and is positioned just above the
   1202 command-line.
   1203 
   1204 
   1205 EDIT
   1206 
   1207 You can now use commands to move around and edit the text in the window.  Both
   1208 in Normal mode and Insert mode.
   1209 
   1210 It is possible to use ":", "/" and other commands that use the command-line,
   1211 but it's not possible to open another command-line window then.  There is no
   1212 nesting.
   1213 						*E11* *E1188*
   1214 The command-line window is not a normal window.  It is not possible to move to
   1215 another window or edit another buffer.  All commands that would do this are
   1216 disabled in the command-line window.  Of course it _is_ possible to execute
   1217 any command that you entered in the command-line window.  Other text edits are
   1218 discarded when closing the window.
   1219 
   1220 
   1221 CLOSE							*E199*
   1222 
   1223 There are several ways to leave the command-line window:
   1224 
   1225 <CR>		Execute the command-line under the cursor.  Works both in
   1226 	Insert and in Normal mode.
   1227 CTRL-C		Continue in Command-line mode.  The command-line under the
   1228 	cursor is used as the command-line.  Works both in Insert and
   1229 	in Normal mode.  There is no redraw, thus the window will
   1230 	remain visible.
   1231 :quit		Discard the command line and go back to Normal mode.
   1232 	":close", CTRL-W c, ":exit", ":xit" and CTRL-\ CTRL-N also
   1233 	work.
   1234 :qall		Quit Vim, unless there are changes in some buffer.
   1235 :qall!		Quit Vim, discarding changes to any buffer.
   1236 
   1237 Once the command-line window is closed the old window sizes are restored.  The
   1238 executed command applies to the window and buffer where the command-line was
   1239 started from.  This works as if the command-line window was not there, except
   1240 that there will be an extra screen redraw.
   1241 The buffer used for the command-line window is deleted.  Any changes to lines
   1242 other than the one that is executed with <CR> are lost.
   1243 
   1244 If you would like to execute the command under the cursor and then have the
   1245 command-line window open again, you may find this mapping useful: >
   1246 
   1247 :autocmd CmdwinEnter * map <buffer> <F5> <CR>q:
   1248 
   1249 
   1250 VARIOUS
   1251 
   1252 The command-line window cannot be used when there already is a command-line
   1253 window (no nesting).
   1254 
   1255 Some options are set when the command-line window is opened:
   1256 'filetype'	"vim", when editing an Ex command-line; this starts Vim syntax
   1257 	highlighting if it was enabled
   1258 'rightleft'	off
   1259 'modifiable'	on
   1260 'buftype'	"nofile"
   1261 'swapfile'	off
   1262 
   1263 It is allowed to write the buffer contents to a file.  This is an easy way to
   1264 save the command-line history and read it back later.
   1265 
   1266 If the 'wildchar' option is set to <Tab>, and the command-line window is used
   1267 for an Ex command, then two mappings will be added to use <Tab> for completion
   1268 in the command-line window, like this: >
   1269 :inoremap <buffer> <Tab> <C-X><C-V>
   1270 :nnoremap <buffer> <Tab> a<C-X><C-V>
   1271 Note that hitting <Tab> in Normal mode will do completion on the next
   1272 character.  That way it works at the end of the line.
   1273 If you don't want these mappings, disable them with: >
   1274 au CmdwinEnter [:>] iunmap <buffer> <Tab>
   1275 au CmdwinEnter [:>] nunmap <buffer> <Tab>
   1276 You could put these lines in your vimrc file.
   1277 
   1278 While in the command-line window you cannot use the mouse to put the cursor in
   1279 another window, or drag statuslines of other windows.  You can drag the
   1280 statusline of the command-line window itself and the statusline above it.
   1281 Thus you can resize the command-line window, but not others.
   1282 
   1283 The |getcmdwintype()| function returns the type of the command-line being
   1284 edited as described in |cmdwin-char|.
   1285 
   1286 Nvim defines this default CmdwinEnter autocmd in the "nvim.cmdwin" group: >
   1287    autocmd CmdwinEnter [:>] syntax sync minlines=1 maxlines=1
   1288 <
   1289 You can disable this in your config with "autocmd! nvim.cmdwin". |default-autocmds|
   1290 
   1291 
   1292 AUTOCOMMANDS
   1293 
   1294 Two autocommand events are used: |CmdwinEnter| and |CmdwinLeave|.  You can use
   1295 the Cmdwin events to do settings specifically for the command-line window.
   1296 Be careful not to cause side effects!
   1297 Example: >
   1298 :au CmdwinEnter :  let b:cpt_save = &cpt | set cpt=.
   1299 :au CmdwinLeave :  let &cpt = b:cpt_save
   1300 This sets 'complete' to use completion in the current window for |i_CTRL-N|.
   1301 Another example: >
   1302 :au CmdwinEnter [\/\?]  startinsert
   1303 This will make Vim start in Insert mode in the command-line window.
   1304 Note: The "/" and "?" needs to be escaped, as this is a |file-pattern|.
   1305 See also |cmdline-autocompletion|.
   1306 
   1307 				*cmdline-char* *cmdwin-char*
   1308 The character used for the pattern indicates the type of command-line:
   1309 :	normal Ex command
   1310 >	debug mode command |debug-mode|
   1311 /	forward search string
   1312 ?	backward search string
   1313 =	expression for "= |expr-register|
   1314 @	string for |input()|
   1315 `-`	text for |:insert| or |:append|
   1316 
   1317 ==============================================================================
   1318 8. Command-line autocompletion			 *cmdline-autocompletion*
   1319 
   1320 Autocompletion makes the command-line more efficient and easier to navigate by
   1321 automatically showing a popup menu of suggestions as you type, whether
   1322 searching (/ or ?) or entering commands (:).
   1323 
   1324 A basic setup is: >
   1325 autocmd CmdlineChanged [:\/\?] call wildtrigger()
   1326 set wildmode=noselect:lastused,full
   1327 set wildoptions=pum
   1328 
   1329 With this configuration, suggestions appear immediately, and you can
   1330 move through them with <Tab> or the arrow keys.
   1331 
   1332 To retain normal command-line history navigation with <Up>/<Down>: >
   1333 cnoremap <expr> <Up>   wildmenumode() ? "\<C-E>\<Up>"   : "\<Up>"
   1334 cnoremap <expr> <Down> wildmenumode() ? "\<C-E>\<Down>" : "\<Down>"
   1335 
   1336 Options can also be applied only for specific command-lines.  For
   1337 example, to use a shorter popup menu height only during search: >
   1338 autocmd CmdlineEnter [\/\?] set pumheight=8
   1339 autocmd CmdlineLeave [\/\?] set pumheight&
   1340 
   1341 EXTRAS					*fuzzy-file-picker* *live-grep*
   1342 
   1343 Command-line autocompletion can also be extended for advanced uses.
   1344 For example, you can turn the native |:find| command into a fuzzy, interactive
   1345 file picker: >
   1346 
   1347 set findfunc=Find
   1348 func Find(arg, _)
   1349   if empty(s:filescache)
   1350     let s:filescache = globpath('.', '**', 1, 1)
   1351     call filter(s:filescache, '!isdirectory(v:val)')
   1352     call map(s:filescache, "fnamemodify(v:val, ':.')")
   1353   endif
   1354   return a:arg == '' ? s:filescache : matchfuzzy(s:filescache, a:arg)
   1355 endfunc
   1356 let s:filescache = []
   1357 autocmd CmdlineEnter : let s:filescache = []
   1358 
   1359 The `:Grep` command searches for lines matching a pattern and updates the
   1360 results dynamically as you type (triggered after two characters; note: needs
   1361 the `CmdlineLeavePre` autocmd from the next section): >
   1362 
   1363 command! -nargs=+ -complete=customlist,<SID>Grep
   1364 	\ Grep call <SID>VisitFile()
   1365 
   1366 func s:Grep(arglead, cmdline, cursorpos)
   1367   if match(&grepprg, '\$\*') == -1 | let &grepprg ..= ' $*' | endif
   1368   let cmd = substitute(&grepprg, '\$\*', shellescape(escape(a:arglead, '\')), '')
   1369   return len(a:arglead) > 1 ? systemlist(cmd) : []
   1370 endfunc
   1371 
   1372 func s:VisitFile()
   1373   let item = getqflist(#{lines: [s:selected]}).items[0]
   1374   let pos  = '[0,\ item.lnum,\ item.col,\ 0]'
   1375   exe $':b +call\ setpos(".",\ {pos}) {item.bufnr}'
   1376   call setbufvar(item.bufnr, '&buflisted', 1)
   1377 endfunc
   1378 
   1379 Automatically select the first item in the completion list when leaving the
   1380 command-line, and for `:Grep`, add the typed pattern to the command-line
   1381 history: >
   1382 
   1383 autocmd CmdlineLeavePre :
   1384       \ if get(cmdcomplete_info(), 'matches', []) != [] |
   1385       \   let s:info = cmdcomplete_info() |
   1386       \   if getcmdline() =~ '^\s*fin\%[d]\s' && s:info.selected == -1 |
   1387       \     call setcmdline($'find {s:info.matches[0]}') |
   1388       \   endif |
   1389       \   if getcmdline() =~ '^\s*Grep\s' |
   1390       \     let s:selected = s:info.selected != -1
   1391       \         ? s:info.matches[s:info.selected] : s:info.matches[0] |
   1392       \     call setcmdline(s:info.cmdline_orig) |
   1393       \   endif |
   1394       \ endif
   1395 
   1396 For autocompletion in insert mode, see |ins-autocompletion|.
   1397 
   1398 vim:tw=78:ts=8:noet:ft=help:norl: