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?
-
I don't believe this should be a duplicate. One is asking about GUI text editors while the other is asking about CLI text editors. – Matt Feb 05 '18 at 18:53
2 Answers
UPDATE
Sublime Text 4 (builds 4000 and higher) has been released, and is the preferred version of Sublime Text to use. There are instructions on Sublime's website for installation using the package repositories (apt
, pacman
, yum
, dnf
, and zypper
) for a number of popular Linux distributions. However, even installing in this way doesn't automagically make all text/source files open with Sublime, so you'll likely still need to follow the directions below.
These instructions assume that you have installed Sublime Text either using the .deb
file provided for Debian/Ubuntu-based systems, or using the apt
repository instructions linked above. If you downloaded the tarball and installed it manually to a location other than /opt/sublime_text
, you will need to change the paths below to your install location.
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:
subl /usr/share/applications/defaults.list
Search for all instances of gedit
(org.gnome.gedit
on some systems) 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:
subl /usr/share/applications/sublime_text.desktop
and paste the following into it:
[Desktop Entry]
Version=1.0
Type=Application
Name=Sublime Text
GenericName=Text Editor
Comment=Sophisticated text editor for code, markup and prose
Exec=/opt/sublime_text/sublime_text %F
Terminal=false
MimeType=text/plain;
Icon=sublime-text
Categories=TextEditor;Development;
StartupNotify=true
Actions=Window;Document;
[Desktop Action Window]
Name=New Window
Exec=/opt/sublime_text/sublime_text -n
OnlyShowIn=Unity;
[Desktop Action Document]
Name=New File
Exec=/opt/sublime_text/sublime_text --command new_file
OnlyShowIn=Unity;
However, if you installed Sublime Text using the .deb
file downloaded from sublimetext.com, the file should already exist.

- 2,125
- 1
- 13
- 18
-
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
-
3I 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 05 '14 at 22:41
-
11btw, its sublime-text not sublime_text, installed from official repo; 14.04 – Gundars Mēness Apr 25 '14 at 10:23
-
2I can not get this to work in Ubuntu 13.10 with Sublime Text 3, not with
sublime_text
norsublime-text
. – matanox Jul 20 '14 at 15:27 -
1
-
I'm using Ubuntu 14.10 with Sublime Text 3 and to make it work I wrote sublime-text (with the dash) – Álvaro Nov 11 '14 at 12:26
-
for some reason I wasnt able to do it on ubuntu 14.10 I was end up installing sublime from Package Manage following the http://askubuntu.com/questions/172698/how-do-i-install-sublime-text-2-3 and everything worked out of the box, then I did diff between the desktop files I found some changes – talsibony Sep 30 '15 at 06:42
-
I got it to work by 1.) renaming the file in
/usr/share/applications/
fromsublime_text.desktop
tosublime-text.desktop
and 2.) removing a duplicaterm ~/.local/share/applications/sublime_text.desktop
. – kleinfreund Nov 01 '16 at 08:48 -
I had to do
sudo subl /usr/share/applications/defaults.list
and change all occurrences ofgedit.desktop
tosublime-text.desktop
. – ViniciusArruda Mar 07 '18 at 22:25 -
-
1if you want a only line solution, you can use:
sudo sed -i "s/org.gnome.gedit/sublime_text/g" /usr/share/applications/defaults.list
. UPDATE: Since Gnome 42 "gedit" was replaced by "TextEditor", so you can update the line with:sudo sed -i "s/org.gnome.TextEditor/sublime_text/g" /usr/share/applications/defaults.list
– Kleber May 03 '23 at 15:45
By using the following steps you can set Sublime as the default editor- :
- Just right-click on any text file
- go to "properties"
- then go to "open with"
- select sublime-text from the lists of applications
- the click on "set as default" tab.
Now your default browser is sublime-text. You can set any app as your default browser by following above method.
-
1I've been doing that, I was hoping to find out if there were a system wide change I could make for all text files. – Dec 29 '13 at 12:58
-
2I 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
-
If it's missing from the list, apply the changes mentioned here: https://askubuntu.com/a/755041/80283 – Muhammad Gelbana Jul 18 '18 at 11:46