Ubuntu – Sublime text as default editor for all text files


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?

Best Answer

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


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

Related Question