Vscode-docs: How to make Code the default editor in Linux?

Created on 28 Feb 2016  路  4Comments  路  Source: microsoft/vscode-docs

In codebasics under ## Windows Management, the sentence "By default, VS Code will open a new window when you double-click on a file outside VS Code..." opens a small can of worms because this doesn't happen by default on most Linuxes (I get gedit by default on Ubuntu if I double click on a file in the nautilus file browser).

I'm also not sure if this is worth documenting. I'm happy with gedit for quick edits of random files, or I'll run Code or xemacs if I want to do more intense editing. So I personally don't care what editor I get if I double-click a text file in a file browser. But perhaps other users would want to use Code for all text file editing.

Unfortunately there doesn't seem to be an easy answer right now. These pages give some ideas:

http://askubuntu.com/questions/289337/how-can-i-change-file-association-globally
http://www.howtogeek.com/117709/how-to-change-your-default-applications-on-ubuntu-4-ways/

but editing the file associations via the file browser, or changing the default editor via "sudo update-alternatives --config editor" don't work because Ubuntu hasn't been informed that there is a new editor available; Code doesn't appear in the menus.

If you come up with a solution, a good place to document it might be in the Q&A section at the end of the codebasics file.

Most helpful comment

This will be in for the March release, if you want to register it in the meantime you can do this:

update-alternatives --install /usr/bin/editor editor <path_to_code> 0
update-alternatives --config editor # set to code

All 4 comments

Is it common to have GUI editors show up in update-alternatives? I notice atom and sublime don't show up, also do you know some instances of where this default is used?

xemacs, which I would consider a GUI editor, shows up in my update-alternatives menu. Apparently the xemacs package knows how to install itself in that menu.
I don't know who specifically uses the default editor, but it's anyone who invokes /usr/bin/editor.
The nautilus file browser must use some other mechanism for knowing about alternative apps, because xemacs does _not_ show up in its menu.

Thanks for the info, moved issue to https://github.com/Microsoft/vscode/issues/3541

This will be in for the March release, if you want to register it in the meantime you can do this:

update-alternatives --install /usr/bin/editor editor <path_to_code> 0
update-alternatives --config editor # set to code
Was this page helpful?
0 / 5 - 0 ratings

Related issues

gitdudek picture gitdudek  路  7Comments

brettcannon picture brettcannon  路  7Comments

tetchel picture tetchel  路  6Comments

jrieken picture jrieken  路  4Comments

yohanmishkin picture yohanmishkin  路  6Comments