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?

3 Answers3

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.

Neikos
  • 451
  • 2
  • 7
  • 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 08 '15 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.

Doorknob
  • 15,237
  • 3
  • 48
  • 70
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.

iKlsR
  • 121
  • 4
  • 2
    This is true, yes, but it is more than that, actually. It is ex-mode in a repl-like shape. – musicmatze Feb 04 '15 at 00: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 04 '15 at 00:28