Change default text editor to Sublime Text in Linux Mint
Solution 1
Open /usr/share/applications/defaults.list
in Sublime:
sudo subl /usr/share/applications/defaults.list
Search for all instances of gedit
and replace them with sublime_text
. Save the file, quit Sublime, log out and back in, and you should be all set.
EDIT
While the above instructions should work with any .deb
-based system (I use Ubuntu), apparently there is an issue with Mint where changes to /usr/share/applications/defaults.list
are lost upon reboot. To work around this, do the following:
- Create a new file (if it doesn't already exist) called
~/.local/share/applications/defaults.list
in Sublime. The first line should be[Default Applications]
. - Open
/usr/share/applications/defaults.list
in Sublime. Hit CtrlF to open theFind
dialog and typegedit
into the search box. - Hit AltEnter or click the
Find All
button to select all the instances ofgedit
in the file. - Hit CtrlL to expand the selections to the entire line, then hit CtrlC to copy the lines.
- In
~/.local/share/applications/defaults.list
, hit CtrlV to paste the lines containinggedit
. - Hit CtrlH to open the
Replace
dialog. Search forgedit
and replace withsublime_text
. Hit CtrlAltEnter to Replace All (or click theReplace All
button) and you're all set. - Save
~/.local/share/applications/defaults.list
, log out and back in, and Sublime Text should now be your default text editor.
Solution 2
so I just figured out a less complicated way to do it.
Step 1: Select any file that you want to open with Sublime. Right-click on it.
Step 2: Go to Properties.
Step 3: Go to Open With
Step 4: Select Sublime
Step 5: Set as Default
Solution 3
If you don't want to edit system files yourself, you can simply go to "Preferred applications" in settings.
Solution 4
Matt's answer worked for me too, many thanks for the clear instructions!
Just to state the obvious, in case it helps someone: if you want a different default editor, then:
ensure it's executable name, eg
vim
replacesgedit
in the ~/.local/share/applications/defaults.list fileensure
export EDITOR=path\executable
is included in the appropriate config file for you (~\.profile
or~\.bashrc
or whatever)
Related videos on Youtube
Mica
Updated on September 18, 2022Comments
-
Mica over 1 year
I've installed Sublime Text 3 from the .deb found here: http://www.sublimetext.com/3
Now, how to set it as the default text editor in place of gedit in Mint 16?
-
Mica over 10 yearsIt works at first, but after rebooting, defaults.list gets reverted, gedit back in place of sublime_text. What can I do to prevent this?
-
Mica over 10 yearsApparently this is an issue with Mint which can be circumvented by using
.local/share/applications/defaults.list
instead. So, I've copied/pasted/edited the gedit lines to this file, and they're now successfully overriding their counterparts in/usr/share/applications/defaults.list
, even after a reboot. -
MattDMo over 10 years@xichael - thanks for the info. I've updated my answer to describe exactly how to set things up to work around this issue. I usually use Ubuntu, where my original solution works fine, and since Mint is quite similar I figured it would work!
-
Cactus BAMF over 9 yearsYou're missing a small step: the first line on ~/.local/share/applications/defaults.list must be "[Default Applications]" for this to work
-
MattDMo over 9 years@Alexandre thanks for that, I'll update the answer. As an Ubuntu user, I've only worked with existing files, so I kinda missed that detail :)
-
user almost 7 years@MattDMo, no need to run Sublime Text as sudo
sudo subl /usr/...
Sublime Text prompts you for the sudo password when you attempt to save a the root file. Anyways, should not it begksudo
for applications? -
Shashank Bhatt almost 3 yearsThe accepted answer should be this.