Handy vim shortcut

Too many times I have started editing a configuration file, or other files that require root privileges, with my normal user account.  A handy vim shortcut:

:w !sudo tee %

allows me to save the file without needing to discard my changes and re-doing them in a new edit session.

Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: