vim :w!!
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.
Written by Bart Lantz
Related protips
6 Responses
Great tip!
This plugin: https://github.com/tpope/vim-eunuch allows similar behaviour.
over 1 year ago
·
works perfectly, thanks
over 1 year ago
·
This is a great tip! Thanks for saving me so many (:q! sudo !!)s
over 1 year ago
·
I prefer cmap w!! w !sudo tee %
over 1 year ago
·
This is gold, thanks
over 1 year ago
·
Excellent.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Related Tags
#vim
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#