Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to replace gedit, and use Sublime Text 3 as my default text editor for all text files on my Ubuntu system. Can you let me know how do I go about making this change?

share|improve this question

marked as duplicate by belacqua, Richard, Maythux, karel, Eric Carvalho Mar 6 '14 at 10:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 57 down vote accepted

First, make sure that /usr/share/applications/sublime_text.desktop exists (sublime-text.desktop on some systems):

ls /usr/share/applications/sublime_text.desktop

Then, open /usr/share/applications/defaults.list with Sublime:

sudo subl /usr/share/applications/defaults.list

Search for all instances of gedit and replace them with sublime_text. Save the file, log out and back in, and you should be all set.

If for some reason /usr/share/applications/sublime_text.desktop (or sublime-text.desktop) doesn't exist, create it:

sudo touch /usr/share/applications/sublime_text.desktop

Open it in Sublime:

sudo subl /usr/share/applications/sublime_text.desktop

and paste the following into it:

[Desktop Entry]
Name=Sublime Text
GenericName=Text Editor
Comment=Sophisticated text editor for code, markup and prose
Exec=/opt/sublime_text/sublime_text %F

[Desktop Action Window]
Name=New Window
Exec=/opt/sublime_text/sublime_text -n

[Desktop Action Document]
Name=New File
Exec=/opt/sublime_text/sublime_text --command new_file

However, if you installed Sublime Text using the .deb file downloaded from, the file should already exist.

share|improve this answer
This desktop file works great on my system except that the "New Window" or "New File" right click actions cause the mouse cursor to go into a busy-spin mode. Everything seems to work normally though... – Digikata Feb 18 '14 at 23:44
I can not get this to work in Ubuntu 13.10 with Sublime Text 2, I did make sure that sublime_text.desktop was changed to reflect sublime-text-2.desktop, any suggestions? – user3165887 Mar 5 '14 at 22:41
btw, its sublime-text not sublime_text, installed from official repo; 14.04 – Gundars Mēness Apr 25 '14 at 10:23
I can not get this to work in Ubuntu 13.10 with Sublime Text 3, not with sublime_text nor sublime-text. – matt Jul 20 '14 at 15:27
Works in Ubuntu 14.10 & Sublime Text 3. Thanks! – Oliboy50 Nov 3 '14 at 12:24

Once you have Sublime installed, right-click on a text file. Go to the "Open With" tab. Select "Show other applications." Then, select Sublime Text 3.

Hope this helps!

share|improve this answer
I've been doing that, I was hoping to find out if there were a system wide change I could make for all text files. – mjwittering Dec 29 '13 at 12:58
I thought that that would change it for all of the txt's... maybe I'm wrong, but I was pretty sure... – masulzen Dec 29 '13 at 16:47

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