I find the command-line window incredibly useful for experimenting with my vim environment. But it's annoying to have to type q: every time I execute a line with <CR>. Is there a way to execute the line under my cursor but not exit the command line window?

The help menu doesn't seem to suggest that. Only how to get out of the command line window.

  • You could have a mapping do <CR>q:
    – D. Ben Knoble
    Jan 19, 2019 at 23:53

1 Answer 1



nnoremap <CR> <CR>q:

This mapping needs to be active only in the command-line window, so,

autocmd CmdwinEnter * nnoremap <buffer> <CR> <CR>q:

Place in your vimrc, preferably surrounded by an augroup/au! definition.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.