I just use https://github.com/tpope/vim-eunuch which includes a :SudoWrite in its list of goodies.
:SudoWrite
Everything in the plugin is pretty easy to live without but in my mind the simple plugin to have everything on-hand is worth it.
Same here since 2014, with the addition of this shortcut in my rc file:
cmap w!! SudoWrite
Nice! I’ve recently added https://github.com/lambdalisue/suda.vim for Neovim, but I may look at this instead, especially as it adds some other things
Here’s part of my .vimrc:
.vimrc
" :W sudo-saves a file
command W w !sudo tee % > /dev/null
This is great, really wish I thought of this earlier! Here’s a oneliner I just put into my vimrc:
command Suwrite exec 'silent write !sudo tee "%" >/dev/null' | edit!
I just use https://github.com/tpope/vim-eunuch which includes a
:SudoWrite
in its list of goodies.Everything in the plugin is pretty easy to live without but in my mind the simple plugin to have everything on-hand is worth it.
Same here since 2014, with the addition of this shortcut in my rc file:
Nice! I’ve recently added https://github.com/lambdalisue/suda.vim for Neovim, but I may look at this instead, especially as it adds some other things
Here’s part of my
.vimrc
:" :W sudo-saves a file
command W w !sudo tee % > /dev/null
This is great, really wish I thought of this earlier! Here’s a oneliner I just put into my vimrc: