开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜