Jamiesutherland.com
RSS icon Email icon Home icon
  • Using vi and forgetting the bastarding sudo command.

    Posted on May 19th, 2009 jsutherland No comments

    OK, so how many of you have been messing about with a system file using vi and you’ve edited about 10 lines. You go to save the file and it complains that it’s Read-Only!! Gah, you then do your thing to correct it and slap yourself for making THAT mistake AGAIN.

    Anyway, rant over. Fix it by doing this!

    vi ~/.vimrc

    Insert this

    command! -bar -nargs=0 Sw :w !sudo tee % >/dev/null

    Now when you go to save and it complains just type :Sw and it will save it out as root and then ask you to reload (If someone know how to do this part automatically it would be appreciated :D )

    Problem solved!

    Leave a reply