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?

  • @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.
    – oblitum
    Oct 8, 2016 at 16:39
  • @peper_chico please update the chosen solution accordingly, cause this is misleading Mar 30, 2020 at 9:13

6 Answers 6


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.
    – oblitum
    Mar 13, 2014 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, 2014 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.
    – Déjà vu
    May 31, 2014 at 9:47
  • 1
    @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". Mar 31, 2016 at 2:41
  • 1
    how come this is not the chosen solution? Mar 30, 2020 at 9:12

This answer only works in Ubuntu 16.04 or prior; the comments have a link to a Xenial release of Ubuntu-Tweak. In newer versions of Ubuntu this will not work as Ubuntu-Tweak is no longer supported by the author.

Comments have suggested that Chris Marx answer below is the right way, but it does not resolve the answer of administrative management - for example, setting the type for many items.

Note: Ubuntu 16.04 is still LTS and Ubuntu 14.04 is not EOL

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:


  • 5
    Note: Ubuntu tweak isn't supported any more and the link provided does not contain the tool mentioned.
    – rohithpr
    Jul 13, 2016 at 10:04
  • 1
    for anyone looking for this: supported or not there's a xenial package in GetDeb repository: ubuntuupdates.org/package/getdeb_apps/xenial/apps/getdeb/…
    – z33k
    Sep 20, 2016 at 15:20
  • 1
    Warning! The current version of Tweaks (at least on Ubuntu 18.04) does not provide this feature. Apr 29, 2019 at 15:57
  • 1
    @LimpingNinja Have you considered deleting this answer as it is no longer applicable (as consolation - there is badge for such action) Nov 10, 2019 at 9:20
  • 1
    @MateuszKonieczny I have considered this, but my concern with deleting the answer is that 16.04 is still supported (LTS) and 14.04 is end of support but not yet EOL. Since there is a package for 16.04, I'll add a tag for now - but would like to know if there is a reasonable answer for > 16.04 that covers this actual scenario. Dec 23, 2019 at 2:23

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, 2014 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. Apr 7, 2016 at 10:33
  • How do you change the mimetypes of files?
    – a06e
    Jun 6, 2019 at 14:05
  • Make sure to log out for changes to register.
    – Andrew
    Jun 19, 2019 at 13:49
  • @becko AFAIK you are unable to change mime type of files, you can change what will open a given mime type. Nov 10, 2019 at 9:21
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? Jun 16, 2013 at 19:29
  • 3
    In my current Ubuntu 14 setup this appears to be mimeapps.list instead of defaults.list.
    – glenatron
    Aug 21, 2014 at 9:35
  • @glenatron Ubuntu 15 works with defaults.list
    – laktak
    Aug 11, 2015 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
    – oblitum
    Jan 14, 2014 at 1:05
  • The OP said explicitly that they are looking for a solution that does not involve Open With (see last line of their question).
    – Oliver
    Apr 18, 2021 at 15:20
  • This could have been added to the question after my answer had been posted (see the dates).
    – z33k
    Apr 19, 2021 at 16:25

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. Oct 28, 2015 at 12:07
  • Thanks for adding that answer. (Although only for completeness' sake.)
    – PythoNic
    Mar 22, 2016 at 14:50
  • 1
    Think about removing the one in .local/share/applications/ if you have a strange behavior.
    – Natim
    Dec 21, 2016 at 21:01

Not the answer you're looking for? Browse other questions tagged .