Alex Rivera | Logout

Is there a way in vim to make :W to do the same thing as :w?

Asked 2012-05-14T19:56:40.213
22

The same goes for :q and :Q. I almost always don't let up on shift quick enough and seeing that :Q and :W aren't used anyway I thought it would be nice to just have them do the same as their lower-case counterparts.

vim
Edit
Report

1 Answer

15

The hack is via a :cmap or :cabb, but these have side effects (i.e. other instances will be inadvertently converted, too).

The cmdalias plugin does this better.

But I think for your use case it's best to define your own uppercase command-variants. The main challenge is to support all the options that the original one has:

command! -bang -range=% -complete=file -nargs=* W <line1>,<line2>write<bang> <args>
command! -bang Q quit<bang>
answered 2012-05-14T20:18:14.147

Your Answer