Skip to content

Instantly share code, notes, and snippets.

@amonks
Created February 13, 2015 14:09
Show Gist options
  • Select an option

  • Save amonks/74f4b34a051d9b367353 to your computer and use it in GitHub Desktop.

Select an option

Save amonks/74f4b34a051d9b367353 to your computer and use it in GitHub Desktop.

If you've opened a file read-only, or if you don't want to run sudo vim for some reason, you can use this trick to save the file anyway.

:w !sudo tee %

Because you're working around the official save behavior, it'll give you a warning that the file has changed on disk, and ask if you would like to reload it. It doesn't matter which option you pick: the version you saved is exactly the same as what's in your buffer already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment