vi/vim to edit root files when you can use Emacs to do it?
Emacs TRAMP mode allows you to easily access and edit remote files as if they were local. So you get the benefits of using all your local settings without the need of close your current instance or open a new one.
I don’t use TRAMP frequently because I don’t need to edit remote files anymore as I used to but it’s interesting to share that you can use TRAMP to edit root local files as long you have
I already shared a post on how to
Open remote files with emacs. The principle is the same but in this case I’ll share how to edit a file that has root permissions.
- Open the file with the root permissions by pressing
C-x C-qto toggle read-only mode for the current buffer.
- When you finish editing the file, type
C-x C-wto save the file.
- Delete the whole existing patch on minibuffer
Note that the
:: double colon is required.
-rw-r--r-- 1 root wheel 895 Jun 20 16:41 myfile.txt
A gif worth more than 1000 words:
You can actually use
TRAMP to open a new dired buffer as root using using
C-x D and then all the following buffers will be opened as sudo.
Few posts related to subject: