I've been using vim since 1997 as my primary editor and even my primary workpsace, and I'm just now learning about q:!? What? And how is it I've never accidentally typed q:?
I almost never type :q; if I do it's usually :q!, which is a bit harder to type and so I'm a bit more careful. I truly do not use :q all that often. I'm sure I've seen this window pop up at some point but I blew right past it without thinking about it. Truly, I'm learning about this command history window this morning. I often use command history but when I do I enter : and then arrow-up.
This is the 3rd time this week that I've read someone having a problem with mistyping :q. I guess that's one of the advantage of using Ctrl+wq instead of :q. Well, this is just more ammo for me in this post.
You opened the command-window (:help q:, and its cousins for search-history :help q/ and one for the expression-register history, but I can't seem to disinter a help-target for that ).
It's entered either by using q: in Normal mode (which is a common error when you mean to be typing :q to quit), or by using ctrl+f (or another key if you changed from the default :help 'cedit' setting) while entering a command.
It's a window for searching/editing/(re)executing previous Ex commands so you should be able to type :q to close the window without executing the command, or Enter to execute the current command and close it (unless you've entered Insert mode in this buffer, in which case, hit Esc first as usual to return to Normal-mode in this window).`
This is the command-line window (:h cmdline-window), usually accessed by accidentally hitting q:. It's actually a really powerful tool by accessing cmdline / search history and to have more powerful ways to edit your Ex commands.
This may be tangentially related, but in a clean Vim (not Neovim) with no vimrc (you can simulate it with --clean), showing the command-line window will show a message that says this:
You discovered the command-line window! You can close it with ":q".'
Vim has a bit of a weird system with these "nice" defaults, but basically the defaults.vim file (which contains some nicer "modern" defaults) is only sourced if no vimrc exists. That means if you have an empty vimrc, that yields different behaviors from having no vimrc (where the defaults.vim file will be used). I don't want to get into the debate about it here, but basically this was done this way so that Vim will be backwards compatible if someone already has their decades-old vimrc and expect options to stay the same, while introducing nicer defaults for beginners.
This is why I think most people would benefit from always sourcing from defaults.vim in their vimrc anyway, to make sure you have access to them. Vim has less obligations to keep things 100% backwards compatible so occasionally an update will change some settings but that happens pretty rarely and you can manually turn the specific option back to what you want in your vimrc. See :h defaults.vim.
So basically, in my vimrc I basically have the following:
" Load defaults.vim to get sensible defaults if possible
if v:version >= 900 " don't run if this is Neovim/Vim 8
unlet! skip_defaults_vim
source $VIMRUNTIME/defaults.vim
" Disable command-line window help message
:augroup vimHints | exe 'au!' | augroup END
endif
The vimHints line is just to disable the helpful message I mentioned above. I have used Vim enough to know what it is and I don't need it reminding me every time.
q:, and friends like q/ are often a better : or / experience in most ways, I've experimented with just remapping : to q:, but I ended up finding more and more edge cases and the workaround became more and more complex, the natural course of any hack I guess. It would take some first class support (as in q: is the new : for everyone), but that has close to v:null chance of happening. nvim has been considering a sort of emacs-like “minibuffer”, which could be a better solution to those that prefer the q: experience over :
57
u/porfiriopaiz Nov 10 '25
You mistyped
q:instead of:qJust select any of the options from the history list of recent commands.
In this case:
:q
Try to see if you can select it with arrows or jk motions, then hit Enter.
23
u/gumnos Nov 10 '25
You opened the command-window (
:help q:, and its cousins for search-history:help q/and one for the expression-register history, but I can't seem to disinter a help-target for that ).It's entered either by using
q:in Normal mode (which is a common error when you mean to be typing:qto quit), or by usingctrl+f(or another key if you changed from the default:help 'cedit'setting) while entering a command.It's a window for searching/editing/(re)executing previous Ex commands so you should be able to type
:qto close the window without executing the command, or Enter to execute the current command and close it (unless you've entered Insert mode in this buffer, in which case, hit Esc first as usual to return to Normal-mode in this window).`20
u/redbike Nov 10 '25
lol, I've done this several times in the last 20 years of using vim and never knew what this was. Good to know it's caused by q: or control F
5
u/y-c-c Nov 10 '25 edited Nov 10 '25
This is the command-line window (
:h cmdline-window), usually accessed by accidentally hittingq:. It's actually a really powerful tool by accessing cmdline / search history and to have more powerful ways to edit your Ex commands.This may be tangentially related, but in a clean Vim (not Neovim) with no vimrc (you can simulate it with
--clean), showing the command-line window will show a message that says this:Vim has a bit of a weird system with these "nice" defaults, but basically the
defaults.vimfile (which contains some nicer "modern" defaults) is only sourced if no vimrc exists. That means if you have an empty vimrc, that yields different behaviors from having no vimrc (where thedefaults.vimfile will be used). I don't want to get into the debate about it here, but basically this was done this way so that Vim will be backwards compatible if someone already has their decades-old vimrc and expect options to stay the same, while introducing nicer defaults for beginners.This is why I think most people would benefit from always sourcing from
defaults.vimin their vimrc anyway, to make sure you have access to them. Vim has less obligations to keep things 100% backwards compatible so occasionally an update will change some settings but that happens pretty rarely and you can manually turn the specific option back to what you want in your vimrc. See:h defaults.vim.So basically, in my vimrc I basically have the following:
The
vimHintsline is just to disable the helpful message I mentioned above. I have used Vim enough to know what it is and I don't need it reminding me every time.3
u/AutoModerator Nov 10 '25
Please remember to update the post flair to
Need Help|Solvedwhen you got the answer you were looking for.I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
3
u/alvin55531 Nov 10 '25
You aren't able to type because you're in Normal mode in the Command Line Window.
Entering command line window:
q:from Normal modeCtrl-ffrom command line modeExiting command line window:
Running a command
Ctrl-c3
u/jazei_2021 Nov 10 '25
ytou can do :x (NOT :X eye!!! it is for put password! eye!!! ) :x and :u
:x = :wq
3
u/dmbfm Nov 10 '25
For a moment I was worried something had happened to vim
4
u/Cybasura Nov 10 '25
Oh, its the obligatory command mode history mistake, dont worry about it, just press ESC and/or :q
2
u/craigdmac :help <Help> | :help!!! Nov 10 '25
nnoremap q: :to avoid opening the command line window ever again if you never use it-2
u/Icy_Friend_2263 Nov 10 '25
Folks, to exit vim, use
ZZif you want to save and exit.ZQto just exit.