Reputation: 721
I want to map w! in vim to save a file using sudo silently (without need to press [Enter] and [L] keys).
Here is a line that works just perfectly:
command! W :execute ':silent w !sudo tee % > /dev/null' | :edit!
But it is W, not w! (with exclamation point)
How do I get that?
Upvotes: 5
Views: 2757
Reputation: 393259
The builtin commands cannot be user-overridden.
You could however do
:cnoreabbrev w! W
to 'magically' translate a lone w
to W
, which has the desired effect, AFAICT
Upvotes: 1