In Vim, Ex mode can and only be entered from Normal mode by Q key.

I accidentally stumbled into Ex mode when I pasted some text incorrectly which somehow trigged the mode switching. Because there was a lot of text, errors, I didnt catch the return command from the message:

Entering Ex mode.  Type "visual" to go to Normal mode.

Quite funny, I was like What the heck is with :? Why am I being stuck in it? Why couldnt I get out of it?

I was totally not aware of this Ex mode, then I remembered skimming over Actually using ed and thats the time I realized that this is Ex mode, which I didnt know Vim has it built in. Then I read Vim 101: ed and ex told me the :visual, I finally got myself out.

1   Entering Ex mode

There are three ways:

  1. Run vim with -e option,
  2. Type Q, or g then Q in Vim, or
  3. Run ex command, on my computer its a symbolic link to Vim binary.

If you use gQ to enter Ex mode, then some functions like completion or inserting contents of named registers, for instance, Ctrl+R, /, can still be used .

Strangely, I can not find any other way like a Vim command to switch. You must use Q key when inside Vim.

2   Leaving Ex mode

  1. Enter visual or vi to switch back to Normal mode.

3   Preventing entering Ex mode

Mapping the Q key to

map Q <Nop>

To revert:

unmap Q