Make :Q! have the same functionality as :q! in vim
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 开发者_StackOverflowaccept :Q! and interpret it as :q! ?
:command -bang Q quit<bang>
For more information, see :help :command-bang
.
I prefer this for my commands
command! -bar -bang Q quit<bang>
- The bang on
:command!
will allow to re-source your vimrc without errors, see:help E174
- The
-bar
argument will allow to concatenate further commands with |, see:help :command-bar
<bang>
expands to ! if one is used, see:help :command-bang
精彩评论