Sublime text as default editor for all text files

16,421

Solution 1

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 using update-alternatives

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
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

Solution 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.

Share:
16,421

Related videos on Youtube

Bran Algue
Author by

Bran Algue

Updated on September 18, 2022

Comments

  • Bran Algue
    Bran Algue over 1 year

    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?

    • mook765
      mook765 about 7 years
      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.
    • Bran Algue
      Bran Algue about 7 years
      I fixed links so that you can see directly text files. No need for dropbox account to see the files.
    • M. Becerra
      M. Becerra about 7 years
      Create an empty file.txt, right-click > Properties > Open with > Select Sublime > Set as default - Is any .txt opened with Sublime now?
    • mook765
      mook765 about 7 years
      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.
    • Bran Algue
      Bran Algue about 7 years
      Amazing spot @mook765! It was sublime-text.desktop on some entries even though it should've been sublime_text.desktop. Now solved.
    • mook765
      mook765 about 7 years
      Great. Would be nice if you put this in an answer then. I will come and upvote.
  • hoijui
    hoijui over 6 years
    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
  • Parth Patel
    Parth Patel almost 5 years
    Please add the comment to the answer itself. It would be much more helpful
  • Giorgi Gvimradze
    Giorgi Gvimradze almost 5 years
    Seriously? those are Wimdows settings...