Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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?

share|improve this question
@AnwarShah The answer already accepted here a long time ago is the same, and it has been working for ages, no more help needed. –  pepper_chico Jul 29 at 6:48

6 Answers 6

up vote 16 down vote accepted

The EASIEST way for you to do this would be to install the program Ubuntu Tweak, this can be downloaded from here: Ubuntu Tweak Download Instructions

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:

share|improve this answer
As I was looking for usability, thanks for this one. Very nice tool. –  pepper_chico May 2 '13 at 2:55
is Ubuntu tweak supported for 13.10? I can't install it.… help plz –  Mina Michael Jan 30 '14 at 17:22
@MinaMichael well I use it without problems on 13.10 –  pepper_chico Mar 3 '14 at 4:48
@pepper_chico I was having trouble with it; some tabs didn't show anything when I opened them. I uninstalled it and went to the software centre to reinstall it but couldn't find it –  Mina Michael Mar 4 '14 at 10:52
@MinaMichael try synaptic, most of times I prefer it. You may also have to use a PPA, don't recall now if I used one. –  pepper_chico Mar 13 '14 at 19:37

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

share|improve this answer
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. –  ring0 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 at 10:05

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.

share|improve this answer
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
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.

share|improve this answer
What if I wanted to open console vim in Xterm instead? –  Adrian Keister Jun 16 '13 at 19:29
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 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: where they also talk about how to change default Terminal programs.

share|improve this answer
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

share|improve this answer

protected by Eric Carvalho Jul 29 at 11:05

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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