1

I have seen other answers, but after following instructions my default editor is LibreOffice, even for txt files.

I want to have Sublime Text 3 as default editor for all text related files: txt, makefile, cpp, h, md, etc.

My default list is full of sublime-text.desktop, and does not contain any libreoffice-writer.desktop. However, all txt files are opened in LibreOffice Writer. The only extension that is opened in sublime text after double clicking is cpp. I can open sublime-text as usual (and also via subl in command line) and can open files from it, but I want to open text files in Sublime Text by double clicking on them. The version of Sublime Text is 3126. Ubuntu is 16.04.

Here is sublime-text.desktop and here is defaults.list.

How can I set sublime text as default editor and why LibreOffice writer opens text files?

  • I don't have a dropbox-account, this might be the reason why I can't see much in your provided links. Other users may have the same problem. – mook765 Apr 4 '17 at 9:16
  • I fixed links so that you can see directly text files. No need for dropbox account to see the files. – Bran Algue Apr 4 '17 at 9:24
  • Create an empty file.txt, right-click > Properties > Open with > Select Sublime > Set as default - Is any .txt opened with Sublime now? – M. Becerra Apr 4 '17 at 10:03
  • 2
    Confusion with dash and underscore? In default.list.txt the entries point to sublime-text.desktop in some cases and to sublime_text.desktopin other cases. – mook765 Apr 4 '17 at 10:08
  • Amazing spot @mook765! It was sublime-text.desktop on some entries even though it should've been sublime_text.desktop. Now solved. – Bran Algue Apr 4 '17 at 10:57
6

The solution provided by Anwesha will work but you will have to manually make sublime text your default opening application for all file formats.

What worked for me in 17.10 was the following: First what you need is the path to the executable file for sublime text I have ST 3 and it was at

/opt/sublime_text/sublime_text

Then open your terminal and use the following commands:

    sudo update-alternatives --install /usr/bin/gnome-text-editor gnome-text-editor /path/to/executablesublime 100

Then enter:

    sudo update-alternatives --config gnome-text-editor

This will bring up a list of the available alternatives, where the default is marked by an asterisk. If sublime text is not it, then select it now by entering corresponding number. Make sure sublime-text's priority is the highest.

And you're done! Hope this helps :D

  • 1
    in addition to this, i also had to edit /usr/share/applications/defaults.list, to remove text/plain=gedit.desktop, for the gnome-text-editor setting to take effect for simple text files. same for other mime types for which you want the default text editor to apply, for example text/x-python=gedit.desktop – hoijui Dec 21 '17 at 14:21
  • Please add the comment to the answer itself. It would be much more helpful – Parth Patel Apr 29 at 15:57
2

To make Sublime Text your default text editor, you need to right-click on any text file, select Properties, then the Open With tab. Select Sublime from the list, and click on the Set as default Button.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.