What does capital W do in VIM?

6

1

in VIM sometimes when saving, I accidentally hit capital W instead of its lowercase brother. I am prompted for my system password, so I assume it is running a sudo command of some sort, but do you know what?

Thank you!

tesmar

Posted 2010-05-26T15:50:34.373

Reputation: 173

1in my vim it gives me "E492: Not an editor command: W" if i try to ":W". – akira – 2010-05-26T16:10:02.783

Ahh..

thank you. I got the vimrc from a friend and it was:

w !sudo tee % > /dev/null – tesmar – 2017-03-01T19:50:30.413

Answers

11

As others have said, :W isn't defined in vanilla vim (7.0 here), so it sounds like some plugin you've installed has added it.

:command W will tell you what it does.

Sam Stokes

Posted 2010-05-26T15:50:34.373

Reputation: 516

6

I guess you have a common mapping for :W in your .vimrc to save the file as typing :w does. Often people press too long the shift key for the colon and make the typo but actually wanting to type :w. You've possibly got this mapping by copy and paste of snippets into your vimrc or by using a pre-configured vim setup such as spf13-vim distribution.

.vimrc:

command! W  write

However, as pointed out by Sam Stokes checking the meaning of commands via

:command W

and for keycombos:

:verbose map < C-j>

is a general approach to find out what a command or keycombo does.

Hotschke

Posted 2010-05-26T15:50:34.373

Reputation: 255

1

You can test this line

{Cursor}It's the test

{Cursor} : Cursor position in normal mode, w: will move word which separated by " ,./?" W: will move word which separated by " " only

Dzung Nguyen

Posted 2010-05-26T15:50:34.373

Reputation: 1 351

0

That's strange. The normal mapping of "W" advances by a WORD, where WORD is defined by a sequence of non-blank characters.

bentsai

Posted 2010-05-26T15:50:34.373

Reputation: 171

1@bentsai: OP is not in control-mode but in ex-mode, as in "instead of :w he uses :W" – akira – 2010-05-26T15:59:17.380

@akira that makes more sense. – bentsai – 2010-05-26T16:00:47.393

0

:W doesn't do anything in my copy of VIM (6.4), for what that's worth. What does :help :W tell you? (For me, it just takes me to the help for :w, which wouldn't be, um, help-ful for you. :-) )

T.J. Crowder

Posted 2010-05-26T15:50:34.373

Reputation: 1 128