Home Explore Blog CI



neovim

5th chunk of `runtime/doc/usr_20.txt`
41c104e8fef8fc4f183e3e248a869f44f2b66fc6eabbe2a40000000100000d55
  |cmdline-history|

Suppose you have done a ":set" command, typed ten more colon commands and then
want to repeat that ":set" command again.  You could press ":" and then ten
times <Up>.  There is a quicker way: >

	:se<Up>

Vim will now go back to the previous command that started with "se".  You have
a good chance that this is the ":set" command you were looking for.  At least
you should not have to press <Up> very often (unless ":set" commands is all
you have done).

The <Up> key will use the text typed so far and compare it with the lines in
the history.  Only matching lines will be used.
   If you do not find the line you were looking for, use <Down> to go back to
what you typed and correct that.  Or use CTRL-U to start all over again.

To see all the lines in the history: >

	:history

That's the history of ":" commands.  The search history is displayed with this
command: >

	:history /

CTRL-P will work like <Up>, except that it doesn't matter what you already
typed.  Similarly for CTRL-N and <Down>.  CTRL-P stands for previous, CTRL-N
for next.

==============================================================================
*20.5*	Command line window

Typing the text in the command line works differently from typing text in
Insert mode.  It doesn't allow many commands to change the text.  For most
commands that's OK, but sometimes you have to type a complicated command.
That's where the command line window is useful.

Open the command line window with this command: >

	q:

Vim now opens a (small) window at the bottom.  It contains the command line
history, and an empty line at the end:
>
	+-------------------------------------+
	|other window			      |
	|~				      |
	|file.txt=============================|
	|:e c				      |
	|:e config.h.in			      |
	|:set path=.,/usr/include,,	      |
	|:set iskeyword=@,48-57,_,192-255     |
	|:set is			      |
	|:q				      |
	|:				      |
	|command-line=========================|
	|				      |
	+-------------------------------------+
<
You are now in Normal mode.  You can use the "hjkl" keys to move around.  For
example, move up with "5k" to the ":e config.h.in" line.  Type "$h" to go to
the "i" of "in" and type "cwout".  Now you have changed the line to:

	:e config.h.out ~

Now press <Enter> and this command will be executed.  The command line window
will close.
   The <Enter> command will execute the line under the cursor.  It doesn't
matter whether Vim is in Insert mode or in Normal mode.
   Changes in the command line window are lost.  They do not result in the
history to be changed.  Except that the command you execute will be added to
the end of the history, like with all executed commands.

The command line window is very useful when you want to have overview of the
history, lookup a similar command, change it a bit and execute it.  A search
command can be used to find something.
   In the previous example the "?config" search command could have been used
to find the previous command that contains "config".  It's a bit strange,
because you are using a command line to search in the command line window.
While typing that search command you can't open another command line window,
there can be only one.

==============================================================================

Next chapter: |usr_21.txt|  Go away and come back

Copyright: see |manual-copyright|  vim:tw=78:ts=8:noet:ft=help:norl:

Title: Command Line Window in Vim
Summary
This section describes the command line window in Vim, accessed using `q:`. It allows users to edit and execute previous commands from the history using normal mode commands. Changes in the command line window do not modify the history, but the executed command is added. The command line window facilitates reviewing, modifying, and executing historical commands. You can use search commands like "?config" to find previous commands.