I know I could use something like Ubuntu Tweak to change the file associations for each file. But I am wondering if there is a way to do it faster and just set the system so that all the files that would have been opened by gedit are now going to be handled by gvim.


Right click the file you want to open, select "Open With other application". A Window will pop-up containing a list of all the installed programs. Select gvim from the list, and make sure "Remember this application..." is selected. That will open all files of that type in gvim. However, that is only half the story, since there are many more file types. Another way is to edit or create this file:


and make sure it contains

[Default Applications]

A recommnded way of doing it is to type this command in a terminal:

sudo update-alternatives --config editor

to update the command line editor, and

sudo update-alternatives --config gnome-text-editor

to update the GUI editor. Enter the number corresponding to the editor that you want to set as you editor, and press enter. That will update all you system references.

That should about do it.

  • I did what you said and I finally got gvim to open text files. With my source files however it still uses gedit. How can I really really tell ubuntu to stop using gedit ANYWHERE and use gvim instead?
    – Shahbaz
    Oct 28 '11 at 13:01
  • What do you mean by source files? Nov 1 '11 at 11:36
  • source files as in .c, .h, .cpp etc! I got my problem solved here
    – Shahbaz
    Nov 1 '11 at 13:30
  • @Shahbaz sed -n '/=gedit\.desktop$/s/gedit/gvim/p' /usr/share/applications/defaults.list >> ~/.local/share/applications/defaults.list This should make all files that open by default with gedit.desktop to be opened by default by gvim.desktop (for your user). There's probably a "better" way, but I like doing it via the terminal.
    – geirha
    Apr 15 '12 at 20:12
  • @geirha, yeah I asked that question and got a similar answer. I have already put the link in my previous comment.
    – Shahbaz
    Apr 15 '12 at 20:17

Just take any file which opens with gedit by default, goto it's properties and change the default app it opens with to gvim. And done!


This question is asked all the time, and none of the answers seem to work 100%.

If you are lazy and don't mind a quick and dirty hack, try this:

sudo mv /usr/bin/gedit /usr/bin/gedit.old
sudo ln -s /usr/bin/gvim /usr/bin/gedit

Your edit windows will still show "GEDIT" in the title bar, but the window will contain gvim.

  • 3
    but beware: as Greg points out, it is a quick but very dirty way. The good thing is.. it works.
    – Mahesh
    Apr 16 '12 at 5:40
  • I did a similar thing and it worked great: sudo apt-get purge gedit ed nano
    – jettero
    Apr 21 '14 at 11:08
  • Frankly speaking, this is the best solution...
    – Xetra
    Apr 23 '18 at 6:47
  • I hate to say it but before changing all the filetypes manually... yeah, sometimes a hammer is the best tool for the job.
    – Red Pill
    Mar 8 '21 at 2:21

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.