I have

cmap w!! %!sudo tee > /dev/null %

in my .vimrc.

When I type a w while writing in the vim command line (after :), the cursor stays over the w for a few seconds before moving right. This sometimes breaks my train of thought and confuses me for a few seconds. Is there a way to make the mapping happen when pressing enter after the command so that it doesn't temporarily "eat" the w every time I press it?

(Incidentally, this mapping also makes w!! expand when I'm typing a search query which isn't annoying in practice (except for the fact that the w is similarly delayed) but seems strange.)


2 Answers 2


I just tried:

cabbrev w!! %!sudo tee > /dev/null %

which delays the expansion until pressing space or enter, but strangely writes the password prompt on top of the expansion of the command, so the command line looks like

Password:ee > /dev/null %

(and works correctly if you ignore the display error).

  • (Anyone know why that happens?) Jun 6, 2012 at 16:56

You can change this behaviour with the timeout and timeoutlen options. To quote the documentation:

If the 'timeout' option is on (which is the default) Vim will only wait for one second (or as long as specified with the 'timeoutlen' option). After that it assumes that the character is to be interpreted as such.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .