How to open a file in ranger as root

file managementrangerrootsudo

How do I open a file in the file-manager "ranger" with superuser rights?

While ":open_with vim" opens the file as none root with vim,
I am looking for something like ":open_with sudo vim", but that does not work.

Best Answer

According to man:

Flags give you a way to modify the behavior of the spawned process. They are used in the commands ":open_with" (key "r") and ":shell" (key "!").

   f   Fork the process.  (Run in background)
   c   Run the current file only, instead of the selection
   r   Run application with root privilege (requires sudo)
   t   Run application in a new terminal window

In your case you would need to use :open_with r vim

Related Question