3

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

2 Answers 2

1

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

[Default Applications]
text/plain=gedit.desktop

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]
Version=1.0
Type=Application
Terminal=false
Icon[en_US]=geany
Name[en_US]=Geany
Exec=/usr/bin/geany
Comment[en_US]=Geany
Name=Geany
Comment=Geany
Icon=geany

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

[Default Applications]
text/plain=geany.desktop
1
  • My mimeapps.list is as follows:-
    – user226737
    Jan 1, 2019 at 22:07
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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