10.7.12

Save in VIM as root! Quick and easy!

Hi all,

Don't have much time, but just ran across this....  So many times I am editing files, in VIM, and I have not issued sudo before hand...   :w .... "Cannot save" Pain in the ASS!

Do this...  edit your ~/.vimrc file and add this little line to'er

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



Save that and all you have to do now is w!! and your good!  Enter your sudo password and away you go.  Now I caution, I would change the w!! to something that you have to think about as w!! can just become habit and habits and sudo are NOT GOOD!   So something like w!root may be a good option.

Just a quick post.
Cheers!
//Ian\\