This question already has an answer here:

gedit is set by default to open about any source file. I've gone through the file properties and changed default application to VIM for C and C++ files.

I'd need to do this for any source file I open now, for python files, for text files, for ruby, any, since gedit is set to open all of them.

How can I change this to open with VIM without going the hassle of setting "open with" one by one?

marked as duplicate by waltinator, Eric Carvalho, Byte Commander, Aaron, pepper_chico Oct 8 '16 at 19:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • @DJCrashdummy this is not a duplicate if you take the time to read the discussion in both questions. Besides this being answered correctly by 3+ years already. – pepper_chico Oct 8 '16 at 16:39

2019-> Readers. Note this answer no longer works at all. See newer answer for one from chrismarx that does though. Save u reading this - the functions is gone here. The answer was accepted 'cos it worked at the time.

The EASIEST way for you to do this would be to install the program Ubuntu Tweak.

Once you have it downloaded you simply open it up, change to Admins tab and then under System choose File Type Manager. Once in here select the file category Text and using shift-click and/or control-click select all of the file types you want, then click Edit on the bottom right.

This will allow you to multi-set the mimetype opener for all of the files.

See screen:



Seems like the answer here

is actually the easiest, specifically going to a file's properties, going to the "open with" tab, and then setting as default for that file type. Here's the picture:

enter image description here

  • 1
    Again, just as I have commented already in o'rety's answer: "this is not as easy when you want to set multiple file types at once or by mime type" and this question is about this. The chosen answer is still the right one. – pepper_chico Mar 13 '14 at 16:11
  • ah my mistake, I was reading that as "setting multiple file's types", not setting multiple default file type associations at once. my mistake- – chrismarx Mar 13 '14 at 17:58
  • This is actually the more natural answer (from the GUI and without manually writing text files or installing 3rd party stuff). It requires a one type at a time setup, though, since Ubuntu does not offer a Open With in a multiple selection -> Properties. – Ring Ø May 31 '14 at 9:47
  • This option doesn't let me add a third-party app, in my case Adobe Reader. – Colin 't Hart Feb 2 '15 at 10:05
  • @ringø I know I'm 2 years behind, but since I'm still the accepted answer it seems, I need to say that your comment about this being the natural answer doesn't resolve the OP question which specifically asks: "How can I change [all source files] to open with VIM without going the hassle of setting "open with" one by one". – LimpingNinja Mar 31 '16 at 2:41

speaking about how things works globally, for the entire system, the most important thing is


which is the file that holds the associations between a given mime type and the application that is supposed to handle that kind of file.

If you don't know the mime type of a file simply use the command


like so

mimetype img.jpg 
img.jpg: image/jpeg

text files, python scripts, web pages, usually any given file has its own mime type.

  • 2
    Please update the path(s) in your answer. I'm saying this because I see /usr/share/applications/defaults.list as a link to /etc/gnome/defaults.list in Lubuntu 13.10. – user25656 Jan 21 '14 at 11:50
  • 2
    In Ubuntu 14.04 changing /usr/share/gnome/applications/defaults.list had no effect for me. Changing /usr/share/applications/defaults.list as suggested did the trick. – Marcus Junius Brutus Apr 7 '16 at 10:33
  • How do you change the mimetypes of files? – becko Jun 6 at 14:05
  • Make sure to log out for changes to register. – Andrew Jun 19 at 13:49
touch ~/.local/share/applications/defaults.list

Add the following lines to ~/.local/share/applications/defaults.list

[Default Applications]

Now every file on your machine will open with gvim, by default.

  • What if I wanted to open console vim in Xterm instead? – Adrian Keister Jun 16 '13 at 19:29
  • 1
    In my current Ubuntu 14 setup this appears to be mimeapps.list instead of defaults.list. – glenatron Aug 21 '14 at 9:35
  • @glenatron Ubuntu 15 works with defaults.list – laktak Aug 11 '15 at 6:35

I guess the easiest graphical way would be:

Files (nautilus) >> select a file >> right click & Properties >> "Open With" tab >> select a program you fancy >> "Select as default". Done.

This method comes from this post on HowToGeek: http://www.howtogeek.com/117709/how-to-change-your-default-applications-on-ubuntu-4-ways/ where they also talk about how to change default Terminal programs.

  • this is not as easy when you want to set multiple file types at once or by mime type – pepper_chico Jan 14 '14 at 1:05

Go to Details from Unity Dash, click on Default Applications on the left pane. Change the file associations as per your preference. No additional installation required and you can set all your default applications from one place.

enter image description here

  • This answer does not show a way to handle C++ files, for example. – LimpingNinja Oct 28 '15 at 12:07
  • Thanks for adding that answer. (Although only for completeness' sake.) – PythoNic Mar 22 '16 at 14:50
  • 1
    Think about removing the one in .local/share/applications/ if you have a strange behavior. – Natim Dec 21 '16 at 21:01

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