Home Explore Blog CI



neovim

17th chunk of `runtime/doc/cmdline.txt`
e056ab2ae9692dac04449396d8ded8430952dcf5dae50aa50000000100000ea1
 several ways to leave the command-line window:

<CR>		Execute the command-line under the cursor.  Works both in
		Insert and in Normal mode.
CTRL-C		Continue in Command-line mode.  The command-line under the
		cursor is used as the command-line.  Works both in Insert and
		in Normal mode.  There is no redraw, thus the window will
		remain visible.
:quit		Discard the command line and go back to Normal mode.
		":close", CTRL-W c, ":exit", ":xit" and CTRL-\ CTRL-N also
		work.
:qall		Quit Vim, unless there are changes in some buffer.
:qall!		Quit Vim, discarding changes to any buffer.

Once the command-line window is closed the old window sizes are restored.  The
executed command applies to the window and buffer where the command-line was
started from.  This works as if the command-line window was not there, except
that there will be an extra screen redraw.
The buffer used for the command-line window is deleted.  Any changes to lines
other than the one that is executed with <CR> are lost.

If you would like to execute the command under the cursor and then have the
command-line window open again, you may find this mapping useful: >

	:autocmd CmdwinEnter * map <buffer> <F5> <CR>q:


VARIOUS

The command-line window cannot be used when there already is a command-line
window (no nesting).

Some options are set when the command-line window is opened:
'filetype'	"vim", when editing an Ex command-line; this starts Vim syntax
		highlighting if it was enabled
'rightleft'	off
'modifiable'	on
'buftype'	"nofile"
'swapfile'	off

It is allowed to write the buffer contents to a file.  This is an easy way to
save the command-line history and read it back later.

If the 'wildchar' option is set to <Tab>, and the command-line window is used
for an Ex command, then two mappings will be added to use <Tab> for completion
in the command-line window, like this: >
	:inoremap <buffer> <Tab> <C-X><C-V>
	:nnoremap <buffer> <Tab> a<C-X><C-V>
Note that hitting <Tab> in Normal mode will do completion on the next
character.  That way it works at the end of the line.
If you don't want these mappings, disable them with: >
	au CmdwinEnter [:>] iunmap <buffer> <Tab>
	au CmdwinEnter [:>] nunmap <buffer> <Tab>
You could put these lines in your vimrc file.

While in the command-line window you cannot use the mouse to put the cursor in
another window, or drag statuslines of other windows.  You can drag the
statusline of the command-line window itself and the statusline above it.
Thus you can resize the command-line window, but not others.

The |getcmdwintype()| function returns the type of the command-line being
edited as described in |cmdwin-char|.

Nvim defines this default CmdwinEnter autocmd in the "nvim.cmdwin" group: >
    autocmd CmdwinEnter [:>] syntax sync minlines=1 maxlines=1
<
You can disable this in your config with "autocmd! nvim.cmdwin". |default-autocmds|


AUTOCOMMANDS

Two autocommand events are used: |CmdwinEnter| and |CmdwinLeave|.  You can use
the Cmdwin events to do settings specifically for the command-line window.
Be careful not to cause side effects!
Example: >
	:au CmdwinEnter :  let b:cpt_save = &cpt | set cpt=.
	:au CmdwinLeave :  let &cpt = b:cpt_save
This sets 'complete' to use completion in the current window for |i_CTRL-N|.
Another example: >
	:au CmdwinEnter [/?]  startinsert
This will make Vim start in Insert mode in the command-line window.

					*cmdline-char* *cmdwin-char*
The character used for the pattern indicates the type of command-line:
	:	normal Ex command
	>	debug mode command |debug-mode|
	/	forward search string
	?	backward search string
	=	expression for "= |expr-register|
	@	string for |input()|
	`-`	text for |:insert| or |:append|

 vim:tw=78:ts=8:noet:ft=help:norl:

Title: Command-Line Window Details: Exiting, Options, and Autocommands
Summary
This section elaborates on exiting the Vim command-line window, listing various commands like <CR>, CTRL-C, :quit, and :qall. It covers various settings applicable in command line window, including filetype, rightleft, modifiable, buftype and swapfile. It mentions options and functionalities such as saving command-line history, tab completion mapping, mouse usage and various commands to access the window. The section details the CmdwinEnter and CmdwinLeave autocommand events and provides examples for customizing the command-line window. It also specifies the characters that indicate the command-line type.