Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vim

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.

like image 852
dwcanillas Avatar asked May 14 '12 19:05

dwcanillas


People also ask

What does capital W do in vim?

For example, :w saves your file and :q allows you to exit Vim.

What does Ctrl d do in vim?

You will see list of commands that matches characters in front of the cursor by pressing CTRL-D in the command mode. For example, if you pressed :se in normal mode, then pressed CTRL-D , you will see list of commands that start with se .

What does CW do in vim?

To quickly change a word you can use cw , caw or ciw . Use c$ or just C to quickly change from the cursor to the end of a line, cc to change an entire line, or cis for a sentence. The standard change word command requires you to type cw , then a new word, then press Escape.


1 Answers

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>
like image 185
Ingo Karkat Avatar answered Sep 28 '22 08:09

Ingo Karkat