'How edit files with Visual Code remote extension using sudo

The Visual Code remote SSH extension allows editing any remote file in the embedded terminal just using code <filename> which is super useful.

However when opening a file with sudo e.g. sudo code /etc/fstabs it returns

sudo: code: command not found

Is there any way to allow the use of code to any user?



Solution 1:[1]

I don't believe this is possible at the time of writing as it would require the underlying node which is running VSCode server to be running with sudo, which it is not.

I have opened a GitHub Issue here.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 davetapley