Here’s a very useful tip
super useful when you open a file that needs sudo perms to edit/save: https://t.co/7Kis1RXa1o i have that bound to C-x C-v #emacs
— Sriram Thaiyar (@s_thai) January 6, 2016
especially if you administer your own machine and often need to edit root-owned files.
If you’re like me, you forget to open the file with SUDO. Fortunately, Emacs protects you from making a lot of changes that you can’t save by marking the buffer read only but you still have to back out of the file and reopen it with SUDO. With Thaiyar’s tiny Elisp function, you can just push a button and automatically re-open the file with SUDO.
Even if you don’t want to install the code in your config file or you find yourself on someone else’s machine, you can do the same trick manually1.
Footnotes:
Although to be fair, it’s not clear that that would be much easier than just starting over.