robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

robinmerge: 1dc9728daa1d8a2702

master
54.1 KiB1401 linesraw
1*cmdline.txt*   Nvim
2
3
4		  VIM REFERENCE MANUAL	  by Bram Moolenaar
5
6
7				*Cmdline-mode* *Command-line-mode* *Cmdline*
8Command-line mode		*cmdline* *Command-line* *mode-cmdline* *:*
9
10Command-line mode is used to enter Ex commands (":"), search patterns
11("/" and "?"), and filter commands ("!").
12
13Basic 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==============================================================================
191. Command-line editing					*cmdline-editing*
20
21Normally characters are inserted in front of the cursor position.  You can
22move 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
25Note that if your keyboard does not have working cursor keys or any of the
26other special keys, you can use ":cnoremap" to define another key for them.
27For 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*
36When the command line is getting longer than what fits on the screen, only the
37part that fits will be shown.  The cursor can only move in this visible part,
38thus you cannot edit beyond that.
39
40						*cmdline-history* *history*
41The command-lines that you enter are remembered in a history table.  You can
42recall them with the up and down cursor keys.  There are actually five
43history 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
51These are completely separate.  Each history can only be accessed when
52entering the same type of line.
53Use the 'history' option to set the number of lines that are remembered.
54
55Notes:
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
66There is an automatic completion of names on the command-line; see
67|cmdline-completion|.
68
69							*c_CTRL-V*
70CTRL-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*
80CTRL-Q		Same as CTRL-V.  But with some terminals it is used for
81		control flow, it doesn't work then.
82
83CTRL-SHIFT-V				*c_CTRL-SHIFT-V* *c_CTRL-SHIFT-Q*
84CTRL-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
103CTRL-B or <Home>				*c_CTRL-B* *c_<Home>* *c_Home*
104		cursor to beginning of command-line
105CTRL-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
117CTRL-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*
123CTRL-W		Delete the |word| before the cursor.  This depends on the
124		'iskeyword' option.
125							*c_CTRL-U*
126CTRL-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*
136CTRL-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
140CTRL-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
191CTRL-R CTRL-F				*c_CTRL-R_CTRL-F* *c_<C-R>_<C-F>*
192CTRL-R CTRL-P				*c_CTRL-R_CTRL-P* *c_<C-R>_<C-P>*
193CTRL-R CTRL-W				*c_CTRL-R_CTRL-W* *c_<C-R>_<C-W>*
194CTRL-R CTRL-A				*c_CTRL-R_CTRL-A* *c_<C-R>_<C-A>*
195CTRL-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>*
210CTRL-R CTRL-R `{register CTRL-F CTRL-P CTRL-W CTRL-A CTRL-L}`
211CTRL-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
218CTRL-\ 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*
243CTRL-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*
249CTRL-Z		Trigger 'wildmode'. Same as 'wildcharm', but always available.
250
251CTRL-M or CTRL-J		*c_CTRL-M* *c_CTRL-J* *c_<NL>* *c_<CR>* *c_CR*
252<CR> or <NL>	start entered command
253
254CTRL-[						*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*
265CTRL-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
283CTRL-D		command-line completion (see |cmdline-completion|)
284'wildchar' option
285		command-line completion (see |cmdline-completion|)
286CTRL-N		command-line completion (see |cmdline-completion|)
287CTRL-P		command-line completion (see |cmdline-completion|)
288CTRL-A		command-line completion (see |cmdline-completion|)
289CTRL-L		command-line completion (see |cmdline-completion|)
290
291							*c_CTRL-^*
292CTRL-^		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-]*
316CTRL-]		Trigger abbreviation, without inserting a character.
317
318For Emacs-style editing on the command-line see |emacs-keys|.
319
320The <Up> and <Down> keys take the current command-line as a search string.
321The beginning of the next/previous command-lines are compared with this
322string.  The first line that matches is the new command-line.  When typing
323these two keys repeatedly, the same string is used again.  For example, this
324can be used to find the previous substitute command: Type ":s" and then <Up>.
325The same could be done by typing <S-Up> a number of times until the desired
326command-line is shown.  (Note: the shifted arrow keys do not work on all
327terminals)
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==============================================================================
3692. Command-line completion				*cmdline-completion*
370
371When editing the command-line, a few commands can be used to complete the
372word 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
385The number of help item matches is limited (currently to 300) to avoid a long
386delay when there are very many matches.
387
388For automatic completion as you type (without pressing a key like <Tab>),
389see |cmdline-autocompletion|.
390
391These are the commands that can be used:
392
393							*c_CTRL-D*
394CTRL-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
401				*c_CTRL-I* *c_wildchar* *c_<Tab>* */_<Tab>*
402'wildchar' option
403		A match is done on the pattern in front of the cursor.  The
404		match (if there are several, the first match) is inserted
405		in place of the pattern.  (Note: does not work inside a
406		macro, because <Tab> or <Esc> are mostly used as 'wildchar',
407		and these have a special meaning in some macros.) When typed
408		again and there were multiple matches, the next
409		match is inserted.  After the last match, the first is used
410		again (wrap around).
411
412		In search context use <CTRL-V><Tab> or "\t" to search for a
413		literal <Tab> instead of triggering completion.
414
415		The behavior can be changed with the 'wildmode' option.
416
417							*c_<S-Tab>*
418<S-Tab>		Like 'wildchar' or <Tab>, but begin with the last match and
419		then go to the previous match.
420
421							*c_CTRL-N*
422CTRL-N		After using 'wildchar' which got multiple matches, go to next
423		match.  Otherwise recall more recent command-line from
424		history.
425
426							*c_CTRL-P*
427CTRL-P		After using 'wildchar' which got multiple matches, go to
428		previous match.  Otherwise recall older command-line from
429		history.
430
431							*c_CTRL-A*
432CTRL-A		All names that match the pattern in front of the cursor are
433		inserted.
434
435							*c_CTRL-L*
436CTRL-L		A match is done on the pattern in front of the cursor.  If
437		there is one match, it is inserted in place of the pattern.
438		If there are multiple matches the longest common part is
439		inserted in place of the pattern.  If the result is shorter
440		than the pattern, no completion is done.
441							*/_CTRL-L*
442		When 'incsearch' is set, entering a search pattern for "/" or
443		"?" and the current match is displayed then CTRL-L will add
444		one character from the end of the current match.  If
445		'ignorecase' and 'smartcase' are set and the command line has
446		no uppercase characters, the added character is converted to
447		lowercase.
448
449	                                            *c_CTRL-G* */_CTRL-G*
450CTRL-G		While the "/" or "?" 'incsearch' prompt is active, CTRL-G
451		moves to the next match (without changing the |jumplist|).
452		The |search-offset| is applied when <CR> is pressed, but does
453		not affect the match highlighting.
454
455		Use CTRL-T to move to the previous match.
456		Mnemonic: on a regular keyboard G is below T.
457
458	                                            *c_CTRL-T* */_CTRL-T*
459CTRL-T		While the "/" or "?" 'incsearch' prompt is active, CTRL-T
460		moves to the previous match (without changing the |jumplist|).
461		The |search-offset| is applied when <CR> is pressed, but does
462		not affect the match highlighting.
463
464		Use CTRL-G to move to the next match.
465		Mnemonic: on a regular keyboard T is above G.
466
467The 'wildchar' option defaults to <Tab> (CTRL-E when in Vi compatible mode; in
468a previous version <Esc> was used).  In the pattern standard |wildcards| are
469accepted when matching file names.
470
471When repeating 'wildchar' or CTRL-N you cycle through the matches, eventually
472ending up back to what was typed.  If the first match is not what you wanted,
473you can use <S-Tab> or CTRL-P to go straight back to what you typed.
474
475The 'wildmenu' option can be set to show the matches just above the command
476line.
477
478The 'wildoptions' option provides additional configuration to use a popup menu
479for 'wildmenu', and to use fuzzy matching.
480
481The 'wildignorecase' option can be set to ignore case in filenames.  For
482completing other texts (e.g. command names), the 'ignorecase' option is used
483instead (fuzzy matching always ignores case, however).
484
485If you like tcsh's autolist completion, you can use this mapping: >
486	:cnoremap X <C-L><C-D>
487(Where X is the command key to use, <C-L> is CTRL-L and <C-D> is CTRL-D)
488This will find the longest match and then list all matching files.
489
490If you like tcsh's autolist completion, you can use the 'wildmode' option to
491emulate it.  For example, this mimics autolist=ambiguous: >
492	:set wildmode=longest,list
493This will find the longest match with the first 'wildchar', then list all
494matching files with the next.
495
496					*complete-script-local-functions*
497When completing user function names, prepend "s:" to find script-local
498functions.
499
500							*suffixes*
501For file name completion you can use the 'suffixes' option to set a priority
502between files with almost the same name.  If there are multiple matches,
503those files with an extension that is in the 'suffixes' option are ignored.
504The default is ".bak,~,.o,.h,.info,.swp,.obj", which means that files ending
505in ".bak", "~", ".o", ".h", ".info", ".swp" and ".obj" are sometimes ignored.
506
507An empty entry, two consecutive commas, match a file name that does not
508contain a ".", thus has no suffix.  This is useful to ignore "prog" and prefer
509"prog.c".
510
511Examples:
512
513  pattern:	files:				match:	~
514   test*	test.c test.h test.o		test.c
515   test*	test.h test.o			test.h and test.o
516   test*	test.i test.h test.c		test.i and test.c
517
518It is impossible to ignore suffixes with two dots.
519
520If there is more than one matching file (after ignoring the ones matching
521the 'suffixes' option) the first file name is inserted.  You can see that
522there is only one match when you type 'wildchar' twice and the completed
523match stays the same.  You can get to the other matches by entering
524'wildchar', CTRL-N or CTRL-P.  All files are included, also the ones with
525extensions matching the 'suffixes' option.
526
527To completely ignore files with some extension use 'wildignore'.
528
529To match only files that end at the end of the typed text append a "$".  For
530example, to match only files that end in ".c": >
531	:e *.c$
532This will not match a file ending in ".cpp".  Without the "$" it does match.
533
534If you would like using <S-Tab> for CTRL-P in an xterm, put this command in
535your .cshrc: >
536	xmodmap -e "keysym Tab = Tab Find"
537And this in your vimrc: >
538	:cmap <Esc>[1~ <C-P>
539<						*complete-set-option*
540When setting an option using |:set=|, the old value of an option can be
541obtained by hitting 'wildchar' just after the '='.  For example, typing
542'wildchar' after ":set dir=" will insert the current value of 'dir'.  This
543overrules file name completion for the options that take a file name.
544
545When using |:set=|, |:set+=|, or |:set^=|, string options that have
546pre-defined names or syntax (e.g. 'diffopt', 'listchars') or are a list of
547single-character flags (e.g. 'shortmess') will also present a list of possible
548values for completion when using 'wildchar'.
549
550When using |:set-=|, comma-separated options like 'diffopt' or 'backupdir'
551will show each item separately.  Flag list options like 'shortmess' will show
552both the entire old value and the individual flags.  Otherwise completion will
553just fill in with the entire old value.
554
555==============================================================================
5563. Ex command-lines					*cmdline-lines*
557
558The Ex commands have a few specialties:
559
560							*:quote* *:comment*
561'"' at the start of a line causes the whole line to be ignored.  '"'
562after a command causes the rest of the line to be ignored.  This can be used
563to add comments.  Example: >
564	:set ai		"set 'autoindent' option
565It is not possible to add a comment to a shell command ":!cmd" or to the
566":map" command and a few others (mainly commands that expect expressions)
567that see the '"' as part of their argument:
568
569    :argdo
570    :autocmd
571    :bufdo
572    :cexpr (and the like)
573    :cdo (and the like)
574    :command
575    :debug
576    :display
577    :echo (and the like)
578    :elseif
579    :execute
580    :folddoopen
581    :folddoclosed
582    :for
583    :grep (and the like)
584    :help (and the like)
585    :if
586    :let
587    :make
588    :map (and the like including :abbrev commands)
589    :menu (and the like)
590    :mkspell
591    :normal
592    :popup
593    :registers
594    :return
595    :sort
596    :syntax
597    :tabdo
598    :tearoff
599    :vimgrep (and the like)
600    :while
601    :windo
602
603							*:bar* *:\bar*
604'|' can be used to separate commands, so you can give multiple commands in one
605line.  If you want to use '|' in an argument, precede it with '\'.
606
607These commands see the '|' as their argument, and can therefore not be
608followed by another Vim command:
609    :append
610    :argdo
611    :autocmd
612    :bufdo
613    :cdo
614    :cfdo
615    :change
616    :command
617    :debug
618    :eval
619    :folddoopen
620    :folddoclosed
621    :function
622    :global
623    :help
624    :helpgrep
625    :insert
626    :ldo
627    :lfdo
628    :lhelpgrep
629    :lsp
630    :make
631    :normal
632    :perlfile
633    :pyfile
634    :python
635    :registers
636    :read !
637    :sign
638    :tabdo
639    :terminal
640    :vglobal
641    :windo
642    :write !
643    :[range]!
644    a user defined command without the "-bar" argument |:command|
645
646Note that this is confusing (inherited from Vi): With ":g" the '|' is included
647in the command, with ":s" it is not.
648
649To be able to use another command anyway, use the ":execute" command.
650Example (append the output of "ls" and jump to the first line): >
651	:execute 'r !ls' | '[
652
653There is one exception: When the 'b' flag is present in 'cpoptions', with the
654":map" and ":abbr" commands and friends CTRL-V needs to be used instead of
655'\'.  You can also use "<Bar>" instead.  See also |map_bar|.
656
657Examples: >
658	:!ls | wc		view the output of two commands
659	:r !ls | wc		insert the same output in the text
660	:%g/foo/p|>		moves all matching lines one shiftwidth
661	:%s/foo/bar/|>		moves one line one shiftwidth
662	:map q 10^V|		map "q" to "10|"
663	:map q 10\| map \ l	map "q" to "10\" and map "\" to "l"
664					(when 'b' is present in 'cpoptions')
665
666You can also use <NL> to separate commands in the same way as with '|'.  To
667insert a <NL> use CTRL-V CTRL-J.  "^@" will be shown.  Using '|' is the
668preferred method.  But for external commands a <NL> must be used, because a
669'|' is included in the external command.  To avoid the special meaning of <NL>
670it must be preceded with a backslash.  Example: >
671	:r !date<NL>-join
672This reads the current date into the file and joins it with the previous line.
673
674Note that when the command before the '|' generates an error, the following
675commands will not be executed.
676
677
678Because of Vi compatibility the following strange commands are supported: >
679	:|			print current line (like ":p")
680	:3|			print line 3 (like ":3p")
681	:3			goto line 3
682
683A colon is allowed between the range and the command name.  It is ignored
684(this is Vi compatible).  For example: >
685	:1,$:s/pat/string
686
687When the character '%' or '#' is used where a file name is expected, they are
688expanded to the current and alternate file name (see the chapter "editing
689files" |:_%| |:_#|).
690
691Trailing spaces in filenames will be ignored, unless escaped with a backslash
692or CTRL-V.  Note that the ":next" command uses spaces to separate file names.
693Escape the spaces to include them in a file name.  Example: >
694	:next foo\ bar goes\ to school\
695starts editing the three files "foo bar", "goes to" and "school ".
696
697When you want to use the special characters '"' or '|' in a command, or want
698to use '%' or '#' in a file name, precede them with a backslash.  The
699backslash is not required in a range and in the ":substitute" command.
700See also |`=|.
701
702							*:_!*
703The '!' (bang) character after an Ex command makes the command behave in a
704different way.  The '!' should be placed immediately after the command,
705without any blanks in between.  If you insert blanks the '!' will be seen as
706an argument for the command, which has a different meaning.  For example:
707	:w! name	write the current buffer to file "name", overwriting
708			any existing file
709	:w !name	send the current buffer as standard input to command
710			"name"
711
712==============================================================================
7134. Ex command-line ranges	*cmdline-ranges* *[range]* *E16*
714
715Some Ex commands accept a line range in front of them.  This is noted as
716[range].  It consists of one or more line specifiers, separated with ',' or
717';'.
718
719The basics are explained in section |10.3| of the user manual.
720
721								*:,* *:;*
722When separated with ';' the cursor position will be set to that line
723before interpreting the next line specifier.  This doesn't happen for ','.
724Examples: >
725   4,/this line/
726<	from line 4 till match with "this line" after the cursor line. >
727   5;/that line/
728<	from line 5 till match with "that line" after line 5.
729
730The default line specifier for most commands is the cursor position, but the
731commands ":write" and ":global" have the whole buffer (1,$) as default.
732
733If more line specifiers are given than required for the command, when comma
734separated, the leftmost one(s) will be ignored, e.g., the -2,+ in this: >
735	:-2,+,-2,. print
736<When semicolon separated, the leftmost specifier to the penultimate one are
737summed, e.g., -4 + 3 - 1 = -2, in this: >
738	:-4;+3;-1;+2 print
739<
740Line numbers may be specified with:		*:range* *{address}*
741	{number}	an absolute line number  *E1247*
742	.		the current line			   *:.*
743	$		the last line of the buffer		   *:$*
744	%		equal to 1,$ (the entire buffer)	   *:%*
745	*		equal to '<,'> (the lines of the last
746			selected Visual area; see |:star| below)
747	'x		the line of the position of mark x	   *:'x*
748			(where x is any {a-z} mark)
749	'X		the line of the position of mark X	   *:'X*
750			(where X is any {A-Z0-9} mark, though
751			when X is in another buffer it cannot
752			be used in a range)
753	'[		the first line of the most recent	   *:'[*
754			change or yank
755	']		the last line of the most recent	   *:']*
756			change or yank
757	'<		the first line of the most recently	   *:'<*
758			selected Visual area
759	'>		the last line of the most recently	   *:'>*
760			selected Visual area
761	''		the line of the position before the	   *:''*
762			latest jump, or where the last "m'"/"m`"
763			command was given (though '' is 1 if it
764			isn't in the current buffer)
765	'"		the line of the cursor position when	   *:'quote*
766			last exiting the buffer
767	'^		the line of the cursor position the	   *:'^*
768			last time Insert mode was stopped
769	'.		the line of the cursor position when the   *:'.*
770			buffer was last changed
771	'(		the line of the first character of the	   *:'(*
772			current sentence
773	')		the line of the first character after	   *:')*
774			the end of the current sentence
775	'{		the first empty line before the		   *:'{*
776			paragraph containing the cursor
777	'}		the first empty line after the		   *:'}*
778			paragraph containing the cursor
779	/{pattern}[/]	the next line where {pattern} matches	   *:/*
780				also see |:range-pattern| below
781	?{pattern}[?]	the previous line where {pattern} matches  *:?*
782				also see |:range-pattern| below
783	\/		the next line where the most recent
784			search pattern matches
785	\?		the previous line where the most recent
786			search pattern matches
787	\&		the next line where the most recent
788			substitute pattern matches
789
790	Note: "next line" and "previous line" do not include matches appearing
791	in the current line.
792
793						*:range-offset*
794Each line specifier may be followed by one or more '+' or '-' and an optional
795number.  That value is added or subtracted from the preceding line number.
796So, for example, 'x+2 is two lines after the line containing mark x.  If the
797number is omitted, +1 is used for each '+' and -1 for each '-' so, e.g., 'x++
798and 'x+2 are synonymous.  If there is nothing before the '+' or '-', for the
799first line number in [range] the current line is used as the relative
800starting point.  So, -,. means, "the line before the current line to the
801current line".  The value of the second line number in [range] depends on
802whether a comma or semicolon separates the line numbers (see |:,| and |:;|).
803Examples: If the cursor is within the line below this one, any of these
804commands will print the tag line ":range-offset" and the line, "Each...": >
805	:-11;+1 print
806	:-----------,-10 print
807	:?Each line?-;+ print
808	:'{+,'{+2 print
809	:'{+1;')-1 print
810<						*:range-closed-fold*
811When a line number after the comma is in a closed fold it is adjusted to the
812last line of the fold, thus the whole fold is included.
813
814When a number is added this is done after the adjustment to the last line of
815the fold.  This means these lines are additionally included in the range.  For
816example: >
817   :3,4+2print
818On this text:
819	1 one ~
820	2 two ~
821	3 three ~
822	4 four FOLDED ~
823	5 five FOLDED ~
824	6 six ~
825	7 seven ~
826	8 eight ~
827Where lines four and five are a closed fold, ends up printing lines 3 to 7.
828The 7 comes from the "4" in the range, which is adjusted to the end of the
829closed fold, which is 5, and then the offset 2 is added.
830
831An example for subtracting (which isn't very useful): >
832   :2,4-1print
833On this text:
834	1 one ~
835	2 two ~
836	3 three FOLDED ~
837	4 four FOLDED ~
838	5 five FOLDED ~
839	6 six FOLDED ~
840	7 seven ~
841	8 eight ~
842Where lines three to six are a closed fold, ends up printing lines 2 to 6.
843The 6 comes from the "4" in the range, which is adjusted to the end of the
844closed fold, which is 6, and then 1 is subtracted, then this is still in the
845closed fold and the last line of that fold is used, which is 6.
846
847							*:range-pattern*
848The "/" and "?" after {pattern} are required to separate the pattern from
849anything that follows.
850
851The "/" and "?" may be preceded with another address.  The search starts from
852there.  The difference from using ';' is that the cursor isn't moved.
853Examples: >
854	/pat1//pat2/	Find line containing "pat2" after line containing
855			"pat1", without moving the cursor.
856	7;/pat2/	Find line containing "pat2", after line 7, leaving
857			the cursor in line 7.
858
859The {number} must be between 0 and the number of lines in the file.  When
860using a 0 (zero) this is interpreted as a 1 by most commands.  Commands that
861use it as a count do use it as a zero (|:tag|, |:pop|, etc).  Some commands
862interpret the zero as "before the first line" (|:read|, search pattern, etc).
863
864Examples: >
865	.+3		three lines below the cursor
866	/that/+1	the line below the next line containing "that"
867	.,$		from current line until end of file
868	0;/that		the first line containing "that", also matches in the
869			first line.
870	1;/that		the first line after line 1 containing "that"
871
872Some commands allow for a count after the command.  This count is used as the
873number of lines to be used, starting with the line given in the last line
874specifier (the default is the cursor line).  The commands that accept a count
875are the ones that use a range but do not have a file name argument (because
876a file name can also be a number).  The count cannot be negative.
877
878Examples: >
879	:s/x/X/g 5	substitute 'x' by 'X' in the current line and four
880			following lines
881	:23d 4		delete lines 23, 24, 25 and 26
882
883
884Folds and Range
885
886When folds are active the line numbers are rounded off to include the whole
887closed fold.  See |fold-behavior|.
888
889
890Reverse Range						*E493*
891
892A range should have the lower line number first.  If this is not the case, Vim
893will ask you if it should swap the line numbers.
894	Backwards range given, OK to swap ~
895This is not done within the global command ":g".
896
897You can use ":silent" before a command to avoid the question, the range will
898always be swapped then.
899
900
901Count and Range						*N:*
902
903When giving a count before entering ":", this is translated into: >
904		:.,.+(count - 1)
905In words: The "count" lines at and after the cursor.  Example: To delete
906three lines: >
907		3:d<CR>		is translated into: .,.+2d<CR>
908<
909
910Visual Mode and Range
911							*v_:*
912{Visual}:	Starts a command-line with the Visual selected lines as a
913		range.  The code `:'<,'>` is used for this range, which makes
914		it possible to select a similar line from the command-line
915		history for repeating a command on different Visually selected
916		lines.
917
918:*						*:star* *:star-visual-range*
919		When Visual mode was already ended, a short way to use the
920		Visual area for a range is `:*`.
921
922==============================================================================
9235. Ex command-line flags				*ex-flags*
924
925These flags are supported by a selection of Ex commands.  They print the line
926that the cursor ends up after executing the command:
927
928	l	output like for |:list|
929	#	add line number
930	p	output like for |:print|
931
932The flags can be combined, thus "l#" uses both a line number and |:list| style
933output.
934
935==============================================================================
9366. Ex special characters				*cmdline-special*
937
938Note: These are special characters in the executed command line.  If you want
939to insert special things while typing you can use the CTRL-R command.  For
940example, "%" stands for the current file name, while CTRL-R % inserts the
941current file name right away.  See |c_CTRL-R|.
942
943Note: If you want to avoid the effects of special characters in a Vim script
944you may want to use |fnameescape()|.  Also see |`=|.
945
946
947In Ex commands, at places where a file name can be used, the following
948characters have a special meaning.  These can also be used in the expression
949function |expand()|.
950	%	Is replaced with the current file name.		  *:_%* *c_%*
951	#	Is replaced with the alternate file name.	  *:_#* *c_#*
952		This is remembered for every window.
953	#n	(where n is a number) is replaced with		  *:_#0* *:_#n*
954		the file name of buffer n.  "#0" is the same as "#".     *c_#n*
955	##	Is replaced with all names in the argument list	  *:_##* *c_##*
956		concatenated, separated by spaces.  Each space in a name
957		is preceded with a backslash.
958	#<n	(where n is a number > 0) is replaced with old	  *:_#<* *c_#<*
959		file name n.  See |:oldfiles| or |v:oldfiles| to get the
960		number.							*E809*
961
962Note that these, except "#<n", give the file name as it was typed.  If an
963absolute path is needed (when using the file name from a different directory),
964you need to add ":p".  See |filename-modifiers|.
965
966The "#<n" item returns an absolute path, but it will start with "~/" for files
967below your home directory.
968
969Note that backslashes are inserted before spaces, so that the command will
970correctly interpret the file name.  But this doesn't happen for shell
971commands.  For those you probably have to use quotes (this fails for files
972that contain a quote and wildcards): >
973	:!ls "%"
974	:r !spell "%"
975
976To avoid the special meaning of '%' and '#' insert a backslash before it.
977Detail: The special meaning is always escaped when there is a backslash before
978it, no matter how many backslashes.
979	you type:		result	~
980	   #			alternate.file
981	   \#			#
982	   \\#			\#
983Also see |`=|.
984
985							*E499* *E500*
986Note: these are typed literally, they are not special keys!
987							*:<cword>* *<cword>*
988	<cword>    is replaced with the word under the cursor (like |star|)
989							*:<cWORD>* *<cWORD>*
990	<cWORD>    is replaced with the WORD under the cursor (see |WORD|)
991							*:<cexpr>* *<cexpr>*
992	<cexpr>    is replaced with the word under the cursor, including more
993		   to form a C expression.  E.g., when the cursor is on "arg"
994		   of "ptr->arg" then the result is "ptr->arg"; when the
995		   cursor is on "]" of "list[idx]" then the result is
996		   "list[idx]".
997							*:<cfile>* *<cfile>*
998	<cfile>    is replaced with the path name under the cursor (like what
999		   |gf| uses)
1000							*:<afile>* *<afile>*
1001	<afile>    When executing autocommands, is replaced with the file name
1002		   of the buffer being manipulated, or the file for a read or
1003		   write.  *E495*
1004							*:<abuf>* *<abuf>*
1005	<abuf>     When executing autocommands, is replaced with the currently
1006		   effective buffer number.  It is not set for all events,
1007		   also see |bufnr()|.  For ":r file" and ":so file" it is the
1008		   current buffer, the file being read/sourced is not in a
1009		   buffer.  *E496*
1010							*:<amatch>* *<amatch>*
1011	<amatch>   When executing autocommands, is replaced with the match for
1012		   which this autocommand was executed.  *E497*
1013		   It differs from <afile> when the file name isn't used to
1014		   match with (for FileType, Syntax and SpellFileMissing
1015		   events).
1016		   When the match is with a file name, it is expanded to the
1017		   full path.
1018							*:<stack>* *<stack>*
1019	<stack>	   is replaced with the call stack, using
1020		   "function {function-name}[{lnum}]" for a function line
1021		   and "script {file-name}[{lnum}]" for a script line, and
1022		   ".." in between items.  E.g.:
1023		   "function {function-name1}[{lnum}]..{function-name2}[{lnum}]"
1024		   If there is no call stack you get error *E489* .
1025							*:<script>* *<script>* *E498*
1026	<script>   When executing a `:source` command, is replaced with the file
1027		   name of the sourced file.  When executing a function, is
1028		   replaced with the file name of the script where it is
1029		   defined.
1030		   If the file name cannot be determined you get error *E1274* .
1031							*:<slnum>* *<slnum>*
1032	<slnum>	   When executing a `:source` command, is replaced with the
1033		   line number.  *E842*
1034		   When executing a function it's the line number relative to
1035		   the start of the function.
1036							*:<sflnum>* *<sflnum>*
1037	<sflnum>   When executing a script, is replaced with the line number.
1038		   It differs from <slnum> in that <sflnum> is replaced with
1039		   the script line number in any situation.  *E961*
1040
1041							 *filename-modifiers*
1042*:_%:* *::8* *::p* *::.* *::~* *::h* *::t* *::r* *::e* *::s* *::gs* *::S*
1043     *%:8* *%:p* *%:.* *%:~* *%:h* *%:t* *%:r* *%:e* *%:s* *%:gs* *%:S*
1044The file name modifiers can be used after "%", "#", "#n", "<cfile>",
1045"<script>", "<afile>" or "<abuf>".  They are also used with the |fnamemodify()|
1046function.
1047
1048These modifiers can be given, in this order:
1049	:p	Make file name a full path.  Must be the first modifier.  Also
1050		changes "~/" (and "~user/" for Unix) to the path for the home
1051		directory.  If the name is a directory a path separator is
1052		added at the end.  For a file name that does not exist and
1053		does not have an absolute path the result is unpredictable.
1054		On MS-Windows an 8.3 filename is expanded to the long name.
1055	:8	Converts the path to 8.3 short format (currently only on
1056		MS-Windows).  Will act on as much of a path that is an
1057		existing path.
1058	:~	Reduce file name to be relative to the home directory, if
1059		possible.  File name is unmodified if it is not below the home
1060		directory.
1061	:.	Reduce file name to be relative to current directory, if
1062		possible.  File name is unmodified if it is not below the
1063		current directory.
1064		For maximum shortness, use ":~:.".
1065	:h	Head of the file name (the last component and any separators
1066		removed).  Cannot be used with :e, :r or :t.
1067		Can be repeated to remove several components at the end.
1068		When the file name ends in a path separator, only the path
1069		separator is removed.  Thus ":p:h" on a directory name results
1070		on the directory name itself (without trailing slash).
1071		When the file name is an absolute path (starts with "/" for
1072		Unix; "x:\" for Win32), that part is not removed.
1073		When there is no head (path is relative to current directory)
1074		the result is empty.
1075	:t	Tail of the file name (last component of the name).  Must
1076		precede any :r or :e.
1077	:r	Root of the file name (the last extension removed).  When
1078		there is only an extension (file name that starts with '.',
1079		e.g., ".nvimrc"), it is not removed.  Can be repeated to
1080		remove several extensions (last one first).
1081	:e	Extension of the file name.  Only makes sense when used alone.
1082		When there is no extension the result is empty.
1083		When there is only an extension (file name that starts with
1084		'.'), the result is empty.  Can be repeated to include more
1085		extensions.  If there are not enough extensions (but at least
1086		one) as much as possible are included.
1087	:s?pat?sub?
1088		Substitute the first occurrence of "pat" with "sub".  This
1089		works like the |:s| command.  "pat" is a regular expression.
1090		Any character can be used for '?', but it must not occur in
1091		"pat" or "sub".
1092		After this, the previous modifiers can be used again.  For
1093		example ":p", to make a full path after the substitution.
1094	:gs?pat?sub?
1095		Substitute all occurrences of "pat" with "sub".  Otherwise
1096		this works like ":s".
1097	:S	Escape special characters for use with a shell command (see
1098		|shellescape()|).  Must be the last one.  Examples: >
1099		    :!dir <cfile>:S
1100		    :call system('chmod +w -- ' .. expand('%:S'))
1101
1102Examples, when the file name is "src/version.c", current dir
1103"/home/mool/vim": >
1104  :p			/home/mool/vim/src/version.c
1105  :p:.				       src/version.c
1106  :p:~				 ~/vim/src/version.c
1107  :h				       src
1108  :p:h			/home/mool/vim/src
1109  :p:h:h		/home/mool/vim
1110  :t					   version.c
1111  :p:t					   version.c
1112  :r				       src/version
1113  :p:r			/home/mool/vim/src/version
1114  :t:r					   version
1115  :e						   c
1116  :s?version?main?		       src/main.c
1117  :s?version?main?:p	/home/mool/vim/src/main.c
1118  :p:gs?/?\\?		\home\mool\vim\src\version.c
1119
1120Examples, when the file name is "src/version.c.gz": >
1121  :p			/home/mool/vim/src/version.c.gz
1122  :e						     gz
1123  :e:e						   c.gz
1124  :e:e:e					   c.gz
1125  :e:e:r					   c
1126  :r				       src/version.c
1127  :r:e						   c
1128  :r:r				       src/version
1129  :r:r:r			       src/version
1130<
1131					*extension-removal* *:_%<*
1132If a "<" is appended to "%", "#", "#n" or "CTRL-V p" the extension of the file
1133name is removed (everything after and including the last '.' in the file
1134name).  This is included for backwards compatibility with version 3.0, the
1135":r" form is preferred.  Examples: >
1136
1137	%		current file name
1138	%<		current file name without extension
1139	#		alternate file name for current window
1140	#<		idem, without extension
1141	#31		alternate file number 31
1142	#31<		idem, without extension
1143	<cword>		word under the cursor
1144	<cWORD>		WORD under the cursor (see |WORD|)
1145	<cfile>		path name under the cursor
1146	<cfile><	idem, without extension
1147
1148Note: Where a file name is expected wildcards expansion is done.  On Unix the
1149shell is used for this, unless it can be done internally (for speed).
1150Backticks work also, like in >
1151	:n `echo *.c`
1152But expansion is only done if there are any wildcards before expanding the
1153'%', '#', etc..  This avoids expanding wildcards inside a file name.  If you
1154want to expand the result of <cfile>, add a wildcard character to it.
1155Examples: (alternate file name is "?readme?")
1156	command		expands to >
1157	:e #		:e ?readme?
1158	:e `ls #`	:e {files matching "?readme?"}
1159	:e #.*		:e {files matching "?readme?.*"}
1160	:cd <cfile>	:cd {file name under cursor}
1161	:cd <cfile>*	:cd {file name under cursor plus "*" and then expanded}
1162Also see |`=|.
1163
1164When the expanded argument contains a "!" and it is used for a shell command
1165(":!cmd", ":r !cmd" or ":w !cmd"), the "!" is escaped with a backslash to
1166avoid it being expanded into a previously used command.  When the 'shell'
1167option contains "sh", this is done twice, to avoid the shell trying to expand
1168the "!".
1169
1170							*filename-backslash*
1171For filesystems that use a backslash as directory separator (Windows
1172filesystems), it's a bit difficult to recognize a backslash that is used
1173to escape the special meaning of the next character.  The general rule is: If
1174the backslash is followed by a normal file name character, it does not have a
1175special meaning.  Therefore "\file\foo" is a valid file name, you don't have
1176to type the backslash twice.
1177
1178An exception is the '$' sign.  It is a valid character in a file name.  But
1179to avoid a file name like "$home" to be interpreted as an environment
1180variable, it needs to be preceded by a backslash.  Therefore you need to use
1181"/\$home" for the file "$home" in the root directory.  A few examples:
1182
1183	FILE NAME	INTERPRETED AS	~
1184	$home		expanded to value of environment var $home
1185	\$home		file "$home" in current directory
1186	/\$home		file "$home" in root directory
1187	\\$home		file "\\", followed by expanded $home
1188
1189Also see |`=|.
1190
1191==============================================================================
11927. Command-line window				*cmdline-window* *cmdwin*
1193							*command-line-window*
1194The command-line window ("cmdwin") is a buffer+window in which the command
1195line can be edited. See also |:exmode|, a REPL-like mode based on the cmdwin.
1196
1197
1198OPEN						*c_CTRL-F* *q:* *q/* *q?*
1199
1200There are two ways to open the command-line window:
12011. From Command-line mode, use <C-F> (or the 'cedit' key).
1202   - Not supported from the expr-register cmdline (|c_CTRL-R_=| |i_CTRL-R_=|).
12032. From Normal mode, use the "q:", "q/" or "q?" command.
1204   This starts editing an Ex command-line ("q:") or search string ("q/" or
1205   "q?").  Note that this is not possible while recording is in progress (the
1206   "q" stops recording then).
1207
1208When the window opens it is filled with the command-line history.  The editor
1209opens in Normal mode.  The last line contains the command as typed so far.  The
1210|cmdwin-char| is shown in 'statuscolumn', indicating the type of command-line.
1211The window is full width, positioned just above the command-line; its height
1212is decided by 'cmdwinheight' (if there is room).
1213
1214Window and tabpage commands work as usual while cmdwin is open: you can
1215navigate, resize, close and open windows/tabpages. The mouse works as in any
1216window: clicks focus other windows, and statuslines and vertical separators
1217can be dragged to resize.
1218
1219								*E1292*
1220Only one command-line window can be open at a time.
1221
1222
1223EDIT
1224
1225You can use any commands to move around and edit the text in the window, both
1226in Normal and Insert mode.
1227
1228It is possible to use ":", "/" and other commands that use the command-line,
1229but it's not possible to open another cmdwin from there.  There is no
1230nesting.
1231
1232
1233CLOSE
1234
1235There are several ways to leave the command-line window:
1236
1237<Enter>		Execute the command-line under the cursor, then close the
1238		window(s) where cmdwin is visible.  Works both in Insert and
1239		in Normal mode.
1240CTRL-C		Continue in Command-line mode.  The command-line under the
1241		cursor is pre-filled in the command-line.  Works both in
1242		Insert and in Normal mode.
1243:quit		Discard the command line and go back to Normal mode.
1244		":close", CTRL-W c, ":exit", ":xit" and CTRL-\ CTRL-N also
1245		work.
1246:qall		Quit Nvim, unless there are changes in some buffer.
1247:qall!		Quit Nvim, discarding changes to any buffer.
1248
1249When the cmdwin closes, focus returns to the window where the command-line
1250was started from (if possible).  The cmdwin scratch buffer is destroyed
1251(`bufhidden=wipe`).  Any text edits other than the line executed by <Enter>
1252are lost.
1253
1254If you would like to execute the command under the cursor and then have the
1255command-line window open again, you may find this mapping useful: >
1256
1257	:autocmd CmdwinEnter * map <buffer> <F5> <CR>q:
1258
1259
1260VARIOUS
1261
1262Buffer and window options set on cmdwin open:
1263'bufhidden'	"wipe"
1264'buflisted'	off
1265'buftype'	"nofile"
1266'filetype'	"vim" (only for ":" type)
1267'foldenable'	off
1268'statuscolumn'	shows the |cmdwin-char|
1269'swapfile'	off
1270
1271It is allowed to write the buffer contents to a file.  This is an easy way to
1272save the command-line history and read it back later.
1273
1274If the 'wildchar' option is set to <Tab>, and the command-line window is used
1275for an Ex command, then two mappings will be added to use <Tab> for completion
1276in the command-line window, like this: >
1277	:inoremap <buffer> <Tab> <C-X><C-V>
1278	:nnoremap <buffer> <Tab> a<C-X><C-V>
1279Note that hitting <Tab> in Normal mode will do completion on the next
1280character.  That way it works at the end of the line.
1281If you don't want these mappings, disable them with: >
1282	au CmdwinEnter [:>] iunmap <buffer> <Tab>
1283	au CmdwinEnter [:>] nunmap <buffer> <Tab>
1284You could put these lines in your vimrc file.
1285
1286The |getcmdwintype()| function returns the type of the command-line being
1287edited as described in |cmdwin-char|.
1288
1289Nvim defines this default CmdwinEnter autocmd in the "nvim.cmdwin" group: >
1290    autocmd CmdwinEnter [:>] syntax sync minlines=1 maxlines=1
1291<
1292You can disable this in your config with "autocmd! nvim.cmdwin". |default-autocmds|
1293
1294
1295AUTOCOMMANDS
1296
1297Two autocommand events are used: |CmdwinEnter| and |CmdwinLeave|.  You can use
1298the Cmdwin events to do settings specifically for the command-line window.
1299Be careful not to cause side effects!
1300Example: >
1301	:au CmdwinEnter :  let b:cpt_save = &cpt | set cpt=.
1302	:au CmdwinLeave :  let &cpt = b:cpt_save
1303This sets 'complete' to use completion in the current window for |i_CTRL-N|.
1304Another example: >
1305	:au CmdwinEnter [\/\?]  startinsert
1306This will make Vim start in Insert mode in the command-line window.
1307Note: The "/" and "?" needs to be escaped, as this is a |file-pattern|.
1308See also |cmdline-autocompletion|.
1309
1310					*cmdline-char* *cmdwin-char*
1311The character used for the pattern indicates the type of command-line:
1312	:	normal Ex command
1313	>	debug mode command |debug-mode|
1314	/	forward search string
1315	?	backward search string
1316	=	expression for "= |expr-register|
1317	@	string for |input()|
1318	`-`	text for |:insert| or |:append|
1319
1320==============================================================================
13218. Command-line autocompletion			 *cmdline-autocompletion*
1322
1323Autocompletion makes the command-line more efficient and easier to navigate by
1324automatically showing a popup menu of suggestions as you type, whether
1325searching (/ or ?) or entering commands (:).
1326
1327A basic setup is: >
1328	autocmd CmdlineChanged [:\/\?] call wildtrigger()
1329	set wildmode=noselect:lastused,full
1330	set wildoptions=pum
1331
1332With this configuration, suggestions appear immediately, and you can
1333move through them with <Tab> or the arrow keys.
1334
1335To retain normal command-line history navigation with <Up>/<Down>: >
1336	cnoremap <expr> <Up>   wildmenumode() ? "\<C-E>\<Up>"   : "\<Up>"
1337	cnoremap <expr> <Down> wildmenumode() ? "\<C-E>\<Down>" : "\<Down>"
1338
1339Options can also be applied only for specific command-lines.  For
1340example, to use a shorter popup menu height only during search: >
1341	autocmd CmdlineEnter [\/\?] set pumheight=8
1342	autocmd CmdlineLeave [\/\?] set pumheight&
1343
1344EXTRAS					*fuzzy-file-picker* *live-grep*
1345
1346Command-line autocompletion can also be extended for advanced uses.
1347For example, you can turn the native |:find| command into a fuzzy, interactive
1348file picker: >
1349
1350	set findfunc=Find
1351	func Find(arg, _)
1352	  if empty(s:filescache)
1353	    let s:filescache = globpath('.', '**', 1, 1)
1354	    call filter(s:filescache, '!isdirectory(v:val)')
1355	    call map(s:filescache, "fnamemodify(v:val, ':.')")
1356	  endif
1357	  return a:arg == '' ? s:filescache : matchfuzzy(s:filescache, a:arg)
1358	endfunc
1359	let s:filescache = []
1360	autocmd CmdlineEnter : let s:filescache = []
1361
1362The `:Grep` command searches for lines matching a pattern and updates the
1363results dynamically as you type (triggered after two characters; note: needs
1364the `CmdlineLeavePre` autocmd from the next section): >
1365
1366	command! -nargs=+ -complete=customlist,<SID>Grep
1367		\ Grep call <SID>VisitFile()
1368
1369	func s:Grep(arglead, cmdline, cursorpos)
1370	  if match(&grepprg, '\$\*') == -1 | let &grepprg ..= ' $*' | endif
1371	  let cmd = substitute(&grepprg, '\$\*', shellescape(escape(a:arglead, '\')), '')
1372	  return len(a:arglead) > 1 ? systemlist(cmd) : []
1373	endfunc
1374
1375	func s:VisitFile()
1376	  let item = getqflist(#{lines: [s:selected]}).items[0]
1377	  let pos  = '[0,\ item.lnum,\ item.col,\ 0]'
1378	  exe $':b +call\ setpos(".",\ {pos}) {item.bufnr}'
1379	  call setbufvar(item.bufnr, '&buflisted', 1)
1380	endfunc
1381
1382Automatically select the first item in the completion list when leaving the
1383command-line, and for `:Grep`, add the typed pattern to the command-line
1384history: >
1385
1386	autocmd CmdlineLeavePre :
1387	      \ if get(cmdcomplete_info(), 'matches', []) != [] |
1388	      \   let s:info = cmdcomplete_info() |
1389	      \   if getcmdline() =~ '^\s*fin\%[d]\s' && s:info.selected == -1 |
1390	      \     call setcmdline($'find {s:info.matches[0]}') |
1391	      \   endif |
1392	      \   if getcmdline() =~ '^\s*Grep\s' |
1393	      \     let s:selected = s:info.selected != -1
1394	      \         ? s:info.matches[s:info.selected] : s:info.matches[0] |
1395	      \     call setcmdline(s:info.cmdline_orig) |
1396	      \   endif |
1397	      \ endif
1398
1399For autocompletion in insert mode, see |ins-autocompletion|.
1400
1401 vim:tw=78:ts=8:noet:ft=help:norl: