60

I am running Ubuntu 15.10.

My /usr/share/applications/sublime_text.desktop contains the following:

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

When I right-click on a markdown file (xxx.md) in Gnome Files (formerly "Nautilus"), I cannot see "Sublime Text" as a choice, even when I select "View All Applications".

I even tried adding %F to the lines Exec=/opt/sublime_text/sublime_text -n and Exec=/opt/sublime_text/sublime_text --command new_file in the [Desktop Action Window] and [Desktop Action Document], respectively, but it did not change anything.

I even ran sudo update-desktop-database.

What am I doing wrong?

Ralph
  • 885

6 Answers6

126

Copy the contents of /usr/share/applications/sublime_text.desktop to ~/.local/share/applications/sublime_text.desktop

Or simply use:

cp -it ~/.local/share/applications /usr/share/applications/sublime_text.desktop

Then in the terminal type: sudo update-desktop-database

David Foerster
  • 36,890
  • 56
  • 97
  • 151
agustaf
  • 1,376
  • 1
  • 8
  • 8
8

In case an old cache does something wrong, simply delete it and let a system make new one for you.

rm ~/.local/share/applications/sublime_text.desktop

It works for me.

Naofumi
  • 181
7

I tried all the options as mentioned in other answers. But, somehow it didn't help me (I'm using Ubuntu 16.04 and installed Sublime-text_build-3126_amd64).

I see this problem occurs in my system only when I install Sublime editor using the package (sublime-text_build-3126_amd64.deb) downloaded from the site. However, installing Sublime from terminal resolves this problem.

I'm yet to figure out technically why there is a difference in the application behaviour between its 2 modes of installation. However, as it works for me, am sharing it here so that it might be helpful for others. The working alternative is:

  1. Uninstall the existing sublime package. Use Synaptic Pkg Mgr and do a complete removal.
  2. Install sublime using the commands:

    For Sublime-Text-2:

    sudo add-apt-repository ppa:webupd8team/sublime-text-2
    sudo apt-get update
    sudo apt-get install sublime-text
    

    For Sublime-Text-3:

    sudo add-apt-repository ppa:webupd8team/sublime-text-3
    sudo apt-get update
    sudo apt-get install sublime-text-installer
    

    Enter subl command to begin instantly.

  3. Right-click on the file you wish to open in the Sublime editor. Now, you could find the application "Sublime text" listed in the menu. Also, you could set the editor as default for the file-type by setting it in the file's properties.

Thanks!:)

umash07
  • 101
2

Do this only if you installed sublime text using 'Ubuntu Make'(umake). Ubuntu Make(umake) makes installing and updating developer tools easier. Type this in terminal.

cat ~/.local/share/applications/sublime-text.desktop

Contents of sublime-text.desktop file will be displayed. Note the following line in the file:

Exec=/home/ja9/.local/share/umake/ide/sublime-text/sublime_text

You need to change that line. Type:

sudo nano ~/.local/share/applications/sublime-text.desktop

The nano text editor is opened, edit that line to

Exec="/home/ja9/.local/share/umake/ide/sublime-text/sublime_text" %F

Make sure you typed capital F, not small. Press 'Ctrl+O'. Press 'enter'. Press 'Ctrl+X'. Type:

sudo update-desktop-database

Problem solved :) , if not, restart system. Note: nano is very good for editing, give it a try(tries)

abyt23
  • 41
0

This worked for me on Ubuntu 20.04

wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -

sudo apt-add-repository "deb https://download.sublimetext.com/ apt/stable/"

sudo apt install sublime-text

0

Open /usr/share/applications/defaults.list (a symlink to /etc/gnome/defaults.list on my system) in Sublime and replace all instances of gedit.desktop with sublime_text.desktop. Save the file and restart your computer - it may be sufficient to log out and back in, but I suspect you'll need to completely quit Gnome for the settings to be reloaded. Once you've logged back in, Sublime Text should be listed in the right-click menu as the default choice for Markdown files, and it should be in the "Open With" menu as well for all file types that can be opened in a text editor.

EDIT:

Here are the contents of my current /usr/share/applications/sublime_text.desktop:

[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;
MattDMo
  • 2,115