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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With