Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.)

share|improve this question
    
Is this from stackoverflow.com/a/7078429 by any chance? –  Tshepang Mar 15 '13 at 9:58
add comment

1 Answer

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).

share|improve this answer
    
(Anyone know why that happens?) –  Ben Alpert Jun 6 '12 at 16:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.