20

Occasionally when I try to quit Vim, I get something that looks like this:

enter image description here

I'm not sure how I accidentally invoke this, but my current method for escaping it is to hit random keys and eventually it goes away. Two questions:

  • How am I invoking it (I use :q to exit vim) accidentally, and
  • How can I exit it quickly and get back to what I'm working on?
2
  • 3
    I disable this keybinding/mode with map q: <Nop> in ~/.vimrc, as I find it very irritating, and never really use it. Feb 5, 2015 at 21:21
  • 1
    PS: you can also map q: :q, which is probably even better.
    – Wolfie
    Oct 6, 2016 at 20:52

3 Answers 3

21

You have invoked it by pressing q: which opens a new window and allows you to write an Ex command. That is why it's called the Command Line

You can read up on it by typing :help q:.

As it is a window you can simply exit it as any other window, notably :q written correctly.

1
  • 5
    Moreover, the Command window is set up so that the command on the cursor line is executed when you press Enter, and your cursor will land on a empty line when you first open the Command window, so simply pressing Enter will close it.
    – tommcdo
    Feb 8, 2015 at 12:49
7

:help Command-line:

                        *Cmdline-mode* *Command-line-mode*
Command-line mode       *Cmdline* *Command-line* *mode-cmdline* *:*

Command-line mode is used to enter Ex commands (":"), search patterns
("/" and "?"), and filter commands ("!").

One of the ways to enter Command Line mode is q:, which you're probably accidentally typing.

This is simply a new window. You can close it via <C-w> q.

On a related note, I suggest using ZZ to save and quit instead. It's easier to type and less prone to mistakes like these.

2

That view shows your recently used commands, you reversed the characters and pressed q: instead. You can use the default <C-w> q to close it.

2
  • 2
    This is true, yes, but it is more than that, actually. It is ex-mode in a repl-like shape.
    – musicmatze
    Feb 4, 2015 at 0:23
  • I know it's the command line mode but I have strangely never used it like that. I use it to check the history Shift V to select a line and enter to execute again.
    – iKlsR
    Feb 4, 2015 at 0:28

Your Answer

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