xp9kjw
Last Updated: July 27, 2016
·
4.61K
· underhilllabs
4004ad8beb489d9d1069b3b928692dae

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.

Say Thanks
Respond

6 Responses
Add your response

6317
98aba6d508f3f1e7fd6b21e8bfdb6b6c

Great tip!

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

over 1 year ago ·
6381
38dd9cc315045603e0694ca58373aa69

works perfectly, thanks

over 1 year ago ·
6391
Regent twitter

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

over 1 year ago ·
6395
88dcd9a1b56c02e905ac3a352e43ba81

I prefer cmap w!! w !sudo tee %

over 1 year ago ·
6443
Aar

This is gold, thanks

over 1 year ago ·
9493

Excellent.

over 1 year ago ·
Filed Under