How Do I Setup Microsoft Visual Studio: Code as a Default Editor?
Solution 1:
From Microsoft VSCode's Doc
Setting VS Code as the default text editor
xdg-open
You can set the default text editor for text files (text/plain) that is used by xdg-open with the following command:
xdg-mime default code.desktop text/plain
Debian alternatives system
Debian-based distributions allow setting a default editor using the alternatives system, without concern for the mime type. You can set this by running the following and selecting code.
sudo update-alternatives --set editor /usr/bin/code
Additionally, there is issue mention following
Some need you to set the default for a mime type like:
~/.local/share/applications/defaults.list
[Default Applications]
text/plain=code-insiders.desktop
Which adds Open With Visual Studio Code - Insiders (Ctrl+O) to the nautilus context menu.
Solution 2:
These two worked for me:
- Using xdg-utils:
xdg-mime default code.desktop text/plain
- In this file:
/usr/share/applications/defaults.list
replace this line:
text/plain=gedit.desktop
with:
text/plain=code.desktop
Note: update-alternatives affects non-graphical environment (terminal) only