I know this question has been asked before, but the answers did not work for me.

I have Ubuntu 18.04. When I try to open a .txt file it attempts to use 'Run'. I can choose Open With Text Editor and the file opens but next time it is back as it was. The 'Set As Default' box is greyed and thus is unavailable so I can't change this permanently. Can anyone suggest what is going onb and how to fix it?


2 Answers 2


Try adding an entry for text/plain to the top of ~/.local/share/applications/mimeapps.list:

[Default Applications]

For this to work the file /usr/share/applications/gedit.desktop needs to exist. If it doesn't, it sounds like your gedit package is broken; try forcing a reinstall as suggested here.

Switching the Default GUI Text Editor

If instead you want to set a different text editor such as Geany as the "default", so that "Open With Geany" shows for all text files instead of "Open With Text Editor":

First, create a file named e.g. geany.desktop in ~/.local/share/applications (there are probably already several .desktop files in there) with the following contents. This question can help with that.

[Desktop Entry]

Then, edit the ~/.local/share/applications/mimeapps.list file and an entry for text/plain at the top of [Default Applications]:

[Default Applications]
  • My mimeapps.list is as follows:-
    – user226737
    Jan 1, 2019 at 22:07

This has been answered before in a sort of duplicate Set VSCode as Default Text Edtior. Just shortly quoting the main trick:

Set VSCode as the default program for that file by right-clicking on the file, Properties, 'Open With' tab.

See the circle, and afterwards, you will see it where the square is:

enter image description here

enter image description here

No new file needed, as far as I can see, as long as you find it in the Open With of the properties, else, you need to follow the answers here and there to create a new desktop launcher in /usr/share/applications first (but I do not think it is needed). As soon as you have chosen your default program, it will also show up in the right-click context menu.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .