Getting the code and installing
Grab the code from here and follow the instructions (they’re in French but pretty easy to follow if you’ve compiled your own software before). Out of the box it recognises .mdtxt files as Markdown files, but I like all my .txt files to be recognised as Markdown too, so I did a bit extra behind my scenes to get this to work.
Setting the association
First thing to do is add the “txt” extension to be recognised as markdown format. Open the file to edit:
gedit /home/nigel/.local/share/mime/packages/x-markdown.xml
then add in the glob pattern for txt files under the current pattern for files so that the file has two lines like this:
<glob pattern="*.mdtxt"/>
<glob pattern="*.txt"/>
Next, remove the txt extension association with plain text. Open the main mime types file (you will probably need to do this as root):
gedit /usr/share/mime/packages/freedesktop.org.xml
and search for the line
<glob pattern="*.txt"/>
This should only appear once and will be in the section for ‘plain/text’.
Once you’ve done these steps, run the following two lines of code (the second may need you to be root):
update-mime-database ~/.local/share/mime/
update-mime-database /usr/share/mime
then restart Gedit and you’ll be all set!