1

Long ago I discovered that q: opens a [Command Line] buffer where I can enter and edit an ex command line using all the power of Vim.

Next, some time ago, I discovered that I can access that mode even while in the middle of editing a command line by pressing Ctrl+f.

For all the above I've found the doc.

But today, I've discovered that hitting Ctrl + C while in that window, the line being edited is copied on the ex prompt which becomes active. It's a bit like it's the inverse of Ctrl+f.

However, I couldn't find the documentation for it. Can you enlighten me?

2 Answers 2

2

For example, type :h q:. It takes you to the file cmdline.txt near the top of the section #7 "Command-line window".

The whole section is, obviously, 100% relevant to the topic. The <C-C> keybinding is mentioned a pair of page-downs under.

Speaking in general, there are 3 main ways:

  1. Press F1. Then scroll down to "REFERENCE MANUAL". Find relevant help file. Browse through the contents, use /, n, N etc. Probably, this is too boring, but I had to mention this.

  2. If you clearly remember something that must be tagged, such as :command then type :h :command (also, make some use of "tab"-completion), look around, follow the links with <C-]> and <C-T> etc.

And even when you're not sure, just naive typing :h something could help you a lot.

  1. If you still have no idea then go with :h :helpgrep.
1

After :help q: and scrolling down a bit:

CLOSE                           *E199*

There are 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:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.