I use nautilus as file manager and would like to use Vim instead of Gedit to edit my text files. Many files (log files, empty files, …) are already opened with Vim, however not all of them, e.g. tex files and XML files are still opened with Gedit.

update-alternatives --get-selections | grep edit yields

editor                auto     /usr/bin/vim.gnome
gnome-text-editor     manual   /usr/bin/vim.gnome
readline-editor       auto     /usr/bin/rlwrap

and I have also set the VISUAL and EDITOR environment variables to point to vim.

Although the questions is about changing the default applicatin for any file type, it is fine to respond with a solution that just addresses the mentioned problem changing the default editor, since that is what bothers me at the moment.


The answer of “hesse” worked for most file types, but not for all. For instance Makefiles are still opened with Gedit. file --mime-type Makefile returns text/plain, which is already included in ~/.local/share/applications/defaults.list. However file --mime-type somefile also returns text/plain but is opened with Vim.

I use Debian unstable.

3 Answers 3


The key is File|Properties. Choose this menu item with a file of the target filetype selected, go to "Open With" tab and press "Reset." Then select an application and press "Set as Default." Kitchen tested on Nautilus 3.2.1.


You should take a look in ~/.local/share/applications/defaults.list under [Default Applications]. There you should set the text/plain to point to the .desktop entry for vim, which is usually located in /usr/share/applications/. E.g:

  • 1
    Can I specify a wildcard? text=gvim.desktop or text/*=gvim.desktop does not work. I want to cover all text files.
    – Marco
    Jan 25, 2012 at 10:26

To change a file association in GNOME Files, e.g. for .txt files:

  1. either
    • right-click on your .txt file and select Properties, or
    • select your .txt file by left-clickin on it and type Ctrl+i

      GNOME Files file context menu
  2. select the Open With tab
  3. select your preferred application
  4. select Set as default (or Reset to use the default application)

    enter image description here
  5. click on to close the Properties window
  • This is duplicating an existing answer, but adds pictures. Instead of providing duplicated answers, you could suggest improvements to existing answers if you think they lack something.
    – Kusalananda
    Mar 21, 2021 at 20:44

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.