Two of the files I occasionally edit are owned by root - if I change their ownesrhip, it screws with the service (home-assistant).
So don’t change their ownership.
Give yourself access to them.
Either add yourself to the group that owns the files (more secure).
Or open the permissions up so that you have access to it from any other user.
Or much simpler....don’t use Visual Studio and learn to vi or at worst nano.
sudo vi nameoffile
Will most definitely work.
If you really want to gui...
sudo gedit nameoffile
Otherwise if you want to go the permissions route...
ls -l nameoffile
IF you are the only user accessing this box and it’s only running at home and you are never going to apply any of this logic in a production system them simply do...
chmod 777 nameoffile
Now do...
ls -l nameoffile
You’ll notice that on the left it’s gone from rwx / rwx / r_x
To
rwx / rwx / rwx
Basically that reads as..
Owner / Group / Other
By doing chmod 777 you change the last Other bit so all users now have full access to it for writing not just reading and executing.
Not secure in general but probably just fine in your use case.
Otherwise you can add your own user to the group that has permission (likely root). OR you assign the file to a group where your user is already included.
The latter is the better way and won’t break anything as root remains the owner.
Basically you are looking for completely the wrong solution due to a fundamental lack of Linux understanding at present. Once you get the permissions structure it will make more sense.