I’ve been a Vim fanatic for a little over a year now, but my first foray into the realm of the super editors was a quick fling with of Emacs. That lasted for about two weeks before I decided that hitting the Control key that often was reducing my quality of life.
A few nights ago I randomly decided to install Emacs on my machine during a bout of insomnia. The next morning I tried to download a file (a VIM script coincidentally) from Firefox and the file opened in Emacs. In fact, every text file I tried to open from the browser opened in Emacs.
I checked my
$EDITOR environment variable, but it was still pointing to Vim.
I tried Chromium and the same thing happened.
I then checked the current XDG default for plain text files using
$ xdg-mime query default text/plain emacs.desktop
A-ha! I now had multiple desktop entries installed that could potentially open text files and I’m guessing xdg-open just uses the most recently added desktop file? I’m not sure. At any rate, Emacs was now set as the default.
$ xdg-mime default gvim.desktop $(grep MimeType /usr/share/applications/gvim.desktop | sed 's/MimeType=//' | tr ';' ' ')
to reset Vim (technically “gvim.desktop”) as the default editor for all of the mime types that Vim can handle. I used grep and sed to grab the list of mime types from the “gvim.desktop” file itself.
I first tried setting the default to the full path to the “gvim.desktop” file, but it turns out that
xdg-mime just wants the base file name.
Anyway, YMMV and all of that, but my files now open in Vim again and I learned a little bit more about XDG/Freedesktop.