To open with VSCode from Nautilus, create a .desktop file, open it in gedit, and paste in the following:
[Desktop Entry]
Name=VSCode
Comment=Edit code files
Exec=code %f
Terminal=false
Type=Application
Icon=code
Categories=TextEditor;
StartupNotify=true
MimeType=text/x-text;
Save the file, then move it to /.local/share/applications
(you may need to open Nautilus via sudo Nautilus
to be able to move it there). It should now appear in the "open with" dialogue when right-clicking on a file. Set VSCode as the default program for that file by right-clicking on the file, Properties, 'Open With' tab. The downside to this method is that it just opens the file, but not the folder in VSCode's 'Explorer' pane.
To open a file with VSCode from the terminal, follow the directions here (Linux section about 1/3 the way down), making sure the paths you use are absolute, not relative. Once that's working, if you cd
to the directory you want and enter code .
it'll open that folder in the VSCode's 'Explorer' pane.
Set VSCode as the default program for that file by right-clicking on the file, Properties, 'Open With' tab.
was what I was searching for. I thought I would have to add files for that, but in reality, I just had to do it with clicks "like in Windows", just in theproperties
was not what I expected. For me, the main thing was not to have a desktop launcher (which did not exist indeed in the list of/usr/share/applications
which I use instead of/.local/share/applications
), but that I did not know how to make it default at all. – questionto42 Mar 04 '22 at 09:52