16

Microsoft Visual Studio Code is a really nice editor and I would like to make it my default normal (not terminal) text-editor over Gedit, Emacs, or Vim. (I know, I'm so evil.)

There's no way for me to add it via a GUI option and I've looked at several online suggestions, but all of them are fairly out of date or unhelpful.

Do any of you have any suggestions? I'll take a terminal solution, but if you guys have a GUI one, that'll do too.

5
  • Did you installing visual studio via wine ?
    – Liso
    Jul 14, 2015 at 2:30
  • @FirstStrike Visual Studio Code is a different, cross-platform thing (see askubuntu.com/questions/616075/…). Ryan: How did you install it?
    – muru
    Jul 14, 2015 at 2:45
  • Definitely native, not Wine. It's actually a pretty nifty editor, give it a try. As for installation, I basically just copied and pasted it into a folder. I launch the program's main executable from that folder.
    – Ryan
    Jul 14, 2015 at 22:55
  • Does Visual studio code exist on /usr/share/applications ?
    – Liso
    Jul 15, 2015 at 3:02
  • The answer depend on how did you install it ?.
    – Liso
    Jul 15, 2015 at 4:35

2 Answers 2

17

From Microsoft Visual Studio Code'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:

bash xdg-mime default code.desktop text/plain

Debian alternatives system

Debian-based distributions allow setting a default editor using the Debian alternatives system, without concern for the MIME type. You can set this by running the following and selecting code:

bash sudo update-alternatives --set editor /usr/bin/code

If Visual Studio Code doesn't show up as an alternative to editor, you need to register it:

bash sudo update-alternatives --install /usr/bin/editor editor $(which code) 10

Additionally, there is this issue mentioning 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.

1
  • 1
    This solution worked for me - thanks! (Actually with VScode snap package on Manjaro distro) Jun 23, 2020 at 7:46
6

These two worked for me:

  1. Using xdg-utils:
xdg-mime default code.desktop text/plain
  1. 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

1
  • For Ubuntu 20.04 works with text/plain=code.desktop inside /usr/share/applications/defaults.list Thanks! Sep 30, 2021 at 11:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .