xp9kjw
Last Updated: October 12, 2018
·
4.705K
· underhilllabs

vim :w!!

vim

Place the following in your .vimrc file

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

Then when you need to make changes to a system file, you can override the read-only permissions by typing :w!!, vim will ask for your sudo password and save your changes.

6 Responses
Add your response

6317

Great tip!

This plugin: https://github.com/tpope/vim-eunuch allows similar behaviour.

over 1 year ago ·
6381

works perfectly, thanks

over 1 year ago ·
6391

This is a great tip! Thanks for saving me so many (:q! sudo !!)s

over 1 year ago ·
6395

I prefer cmap w!! w !sudo tee %

over 1 year ago ·
6443

This is gold, thanks

over 1 year ago ·
9493

Excellent.

over 1 year ago ·