6

There's a lot of tutorials on how to change the default text editor in Unity and Gnome. There's none for Xubuntu/XFCE.

How do I change all mousepad's associations to sublime text?

I know I could install Unity Tweak Tool, but that loads a lot of dependencies, including compiz. I don't want that.

I know I can right click a file and do "Open with". There's a lot of file types I am willing to change (ruby, php, html, css, js, coffee,...), so that's not the way either.

update-alternatives is not the way either:

There are 4 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path               Priority   Status
------------------------------------------------------------
* 0            /usr/bin/vim.gtk    50        auto mode
  1            /bin/ed            -100       manual mode
  2            /bin/nano           40        manual mode
  3            /usr/bin/vim.gtk    50        manual mode
  4            /usr/bin/vim.tiny   10        manual mode

Press enter to keep the current choice[*], or type selection number: 
1

5 Answers 5

7

If you do not want to install additional applications you will have to manually edit ~/.local/share/applications/mimeapps.list

Under the [Added Associations] section add:

application/x-perl=sublime.desktop
text/plain=sublime.desktop
text/x-chdr=sublime.desktop
text/x-csrc=sublime.desktop
text/x-dtd=sublime.desktop
text/x-java=sublime.desktop
text/mathml=sublime.desktop
text/x-python=sublime.desktop
text/x-sql=sublime.desktop
text/x-tex=sublime.desktop
3
  • Thanks for that. Unfortunately those are not all ;) Is there a way to set it via a regex like text/.* or at least list all the text/ mimetypes?
    – mreq
    May 3, 2013 at 18:40
  • Not that I know of, you can try.
    – Panther
    May 3, 2013 at 20:19
  • 2
    There is also defaults.list - you can override any associations in /usr/share/applications/defaults.list in your own ~/.local/share/applications/defaults.list. Same principle for mimeapps.list.
    – user79163
    Jun 13, 2013 at 10:53
7

Just to follow up on bodhi.zazen's answer with a more complete file:

[Added Associations]
application/ecmascript=sublime_text.desktop;
application/javascript=sublime_text.desktop;
application/mathematica=sublime_text.desktop;
application/x-chess-pgn=sublime_text.desktop;
application/x-ccmx=sublime_text.desktop;
application/x-ica=sublime_text.desktop;
application/mathml+xml=sublime_text.desktop;
application/sql=sublime_text.desktop;
application/x-perl=sublime_text.desktop;
application/xml-dtd=sublime_text.desktop;
message/partial=sublime_text.desktop;
message/rfc822=sublime_text.desktop;
message/news=sublime_text.desktop;
model/vrml=sublime_text.desktop;
text/x-java=sublime_text.desktop;
text/xmcd=sublime_text.desktop;
text/x-vhdl=sublime_text.desktop;
text/x-subviewer=sublime_text.desktop;
text/x-adasrc=sublime_text.desktop;
text/x-modelica=sublime_text.desktop;
text/x-objcsrc=sublime_text.desktop;
text/x-ssa=sublime_text.desktop;
text/x-mpsub=sublime_text.desktop;
text/x-txt2tags=sublime_text.desktop;
text/x-svhdr=sublime_text.desktop;
text/x-verilog=sublime_text.desktop;
text/x-troff-ms=sublime_text.desktop;
text/x-mof=sublime_text.desktop;
text/x-readme=sublime_text.desktop;
text/x-uil=sublime_text.desktop;
text/x-scheme=sublime_text.desktop;
text/x-install=sublime_text.desktop;
text/x-log=sublime_text.desktop;
text/x-ooc=sublime_text.desktop;
text/x-uuencode=sublime_text.desktop;
text/x-ms-regedit=sublime_text.desktop;
text/x-ldif=sublime_text.desktop;
text/x-mup=sublime_text.desktop;
text/x-makefile=sublime_text.desktop;
text/x-nfo=sublime_text.desktop;
text/x-lua=sublime_text.desktop;
text/x-pascal=sublime_text.desktop;
text/x-cmake=sublime_text.desktop;
text/x-dsrc=sublime_text.desktop;
text/x-rpm-spec=sublime_text.desktop;
text/x-tex=sublime_text.desktop;
text/x-markdown=sublime_text.desktop;
text/x-microdvd=sublime_text.desktop;
text/x-idl=sublime_text.desktop;
text/x-scala=sublime_text.desktop;
text/x-setext=sublime_text.desktop;
text/x-python=sublime_text.desktop;
text/x-literate-haskell=sublime_text.desktop;
text/x-copying=sublime_text.desktop;
text/x-ocl=sublime_text.desktop;
text/x-dsl=sublime_text.desktop;
text/x-texinfo=sublime_text.desktop;
text/x-dcl=sublime_text.desktop;
text/x-fortran=sublime_text.desktop;
text/x-gettext-translation=sublime_text.desktop;
text/x-erlang=sublime_text.desktop;
text/x-gettext-translation-template=sublime_text.desktop;
text/x-emacs-lisp=sublime_text.desktop;
text/x-iptables=sublime_text.desktop;
text/x-haskell=sublime_text.desktop;
text/x-lilypond=sublime_text.desktop;
text/x-patch=sublime_text.desktop;
text/x-matlab=sublime_text.desktop;
text/x-reject=sublime_text.desktop;
text/x-tcl=sublime_text.desktop;
text/x-svsrc=sublime_text.desktop;
text/x-troff-mm=sublime_text.desktop;
text/x-moc=sublime_text.desktop;
text/x-troff-me=sublime_text.desktop;
text/cache-manifest=sublime_text.desktop;
text/x-eiffel=sublime_text.desktop;
text/enriched=sublime_text.desktop;
text/htmlh=sublime_text.desktop;
text/rfc822-headers=sublime_text.desktop;
text/plain=sublime_text.desktop;
text/troff=sublime_text.desktop;
text/x-vala=sublime_text.desktop;
text/css=sublime_text.desktop;
text/x-c++hdr=sublime_text.desktop;
text/x-c++src=sublime_text.desktop;
text/x-chdr=sublime_text.desktop;
text/x-csharp=sublime_text.desktop;
text/x-csrc=sublime_text.desktop;
1
  • Great list. You can also replace sublime_text.desktop to any other editor, ie I set mine to notepadqq.desktop.
    – Mo Beigi
    Nov 25, 2015 at 3:53
2

What actually helped was to uninstall Mousepad. I was not using it anyway. All the files are now opened in Sublime.

2
1

Although this answer is quite old, I've ended up back here over the years--every time I install Xubuntu on a new machine--and always seem to end up fumbling around when trying to solve this.

It seems the answer has changed somewhat recently. At some point, Xubuntu added a /usr/share/xubuntu/applications/defaults.list, which is where the defaults are actually set. The user overrides are located in ~/.config/mimeapps.list, per this answer.

You can also edit the associations in the MIME Type Editor if you're a fan of clicking a lot.

In the future, in the event this changes again, the best course of action -- since documentation seems to be sparse or difficult to find, with top search results largely being this question, blog posts giving the old location, and blog posts describing how to right-click on things -- might be grep -r "mousepad.desktop" /usr/share/* to find the location of the defaults. To find the user overrides, make a change with the MIME Type Editor and grep in your home folder for the change you made, e.g: grep -r "gvim.desktop" ~/*.

0

Yep in Xubuntu (XFCE Window Manager) you need to use MIME Type Editor and set the default editor of text/plain to whatever you want. This will be the default for "Text Editor" type files.

You must log in to answer this question.

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