Reputation: 3064
Sometimes in vim, I accidentally type :Q instead of :q in normal mode. To work around this, I've added this in my .vimrc:
command Q q
This works fine for :Q, but in case I type :Q!, vim responds with "No ! allowed". How do I make vim accept :Q! and interpret it as :q! ?
Upvotes: 6
Views: 699
Reputation: 5303
I prefer this for my commands
command! -bar -bang Q quit<bang>
:command!
will allow to re-source your vimrc without errors, see :help E174
-bar
argument will allow to concatenate further commands with |, see :help :command-bar
<bang>
expands to ! if one is used, see :help :command-bang
Upvotes: 7
Reputation: 89221
:command -bang Q quit<bang>
For more information, see :help :command-bang
.
Upvotes: 13