When using vi/vim, I would often accidentally bring up the command history. It turned out I was typing q: instead of :q.
In Vim, q: is not the quit command. It opens the command-line window. This window lists Ex commands you have entered before, such as :w, :q, :set number, and so on. Essentially, it is an editable command history list.
Common usage is as follows:
q:: open the:command history window.q/: open the/search history window.q?: open the?search history window.- In the window, use Normal mode to move to a history entry, then press
Enterto execute it. - Press
Ctrl-C, use:q, or close the window to exit the command history window.
If you only want to recall the previous command on the command line, you do not necessarily need to open the command history window. After typing :, you can use the arrow keys or Ctrl-P and Ctrl-N to move through command history:
:
Then press:
Ctrl-P Previous command
Ctrl-N Next command
So if you accidentally press q:, there is no need to panic. Vim has not frozen; you have just entered the command history window. Exit the window and type :q again.
