How Do I Use `Sudo -E` Together with Gvim?

How Do I Use `Sudo -E` Together with Gvim?

So when one edits a file owned by root it is recommended to use sudo -e. This will open a copy of the file in your favorite $EDITOR. Using this together with vim works like a charm.

However, when I want to use the graphical variant, i.e. gvim, it will open an empty file, and the sudo command returns directly, stating that nothing was changed.

Is there a way to make this work?

6
Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.