Friday, October 23, 2009

save file in vi when you forget 'sudo'

:w !sudo tee %

This issue happened to me a lot of times.
After you made some changes in vi and want to save, suddenly you find you don't have the permission~.

Others:
> file.txt
empty the file (or create a new empty file)

Alt-.
place the argument of most recent command (keep pressing for older ones)

-- from commandlinefu.com

No comments:

Post a Comment