Do: Q! have the same functionality as: q! in vim

Sometimes in vim I accidentally type: Q instead of: q in normal mode. To get around this, I added this to my .vimrc:

command Q q

This works fine for: Q, but in case I type: Q !, vim says "No! Allowed". How to make vim accept: Q! and interpret it as: q!

+5
source share
2 answers
:command -bang Q quit<bang>

For more information, see :help :command-bang.

+12
source

I prefer this for my teams

command! -bar -bang Q quit<bang>
  • Hacking on :command!will allow you to redirect your vimrc again without errors, see:help E174
  • The argument -barallows you to combine other commands with |, see:help :command-bar
  • <bang>expands to! if used, see:help :command-bang
+6
source

All Articles