sontek ( John M. Anderson )

June 8, 2008

Vim Tip: Save file with root permissions

Filed under: vim — Tags: — sontek @ 7:06 pm

Have you ever opened up a configuration file in vim and then after you do all your editing you realize you don’t have permissions to save?

A simple command that will re-open your current buffer with root permissions is this:

exe “%!sudo tee %” | e!

You can bind this in your vimrc and then never waste time editing a read-only file again!

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • description
  • Pownce
  • Slashdot
  • StumbleUpon
  • TwitThis

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress