I need to set on my Linux box
VIM as default mime application for editing text file. On
zsh I managed to wrap a function from vim --remote. But I would like to use it for default xdg-mime application (in the same way
emacsclient is doing for emacs).
xdg-open relies on
.desktop files, so you'll have to create on and then associate it with the right mimetypes. If you can't/won't use GVim, you can still piggy-back on its
$ grep -v Comment /usr/share/applications/gvim.desktop [Desktop Entry] Name=GVim GenericName=Text Editor GenericName[de]=Texteditor TryExec=gvim Exec=gvim -f %F Terminal=false Type=Application Icon=vim Categories=Utility;TextEditor; StartupNotify=true MimeType=text/plain;
Copy the contents to a
- using your
vim --remotecommand for
%F, as you might have deduced, will be replaced with the filenames.
Then, copy this to
~/.local/share/applications and mark it as executable:
cp vim.desktop ~/.local/share/applications chmod +x ~/.local/share/applications/vim.desktop
In whatever method you use to access launchers for your installed apps (Unity's Dash, GNOME Shell's Overview, MATE/XFCE/Clementine's menu, etc.), you should see a new Vim entry, indicating that the
.desktop file was correctly created.
Now, to associate it with text files, you can do:
xdg-mime default vim.desktop text/plain