9

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.

Xetra
  • 121
amh
  • 997

3 Answers3

11

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:

~/.local/share/applications/defaults.list

and make sure it contains

[Default Applications]
text/plain=gvim.desktop

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.

theTuxRacer
  • 16,185
  • 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? – theTuxRacer Nov 01 '11 at 11:36
  • source files as in .c, .h, .cpp etc! I got my problem solved here – Shahbaz Nov 01 '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
  • @Shahbaz oops, missed that. Oh well. :) – geirha Apr 15 '12 at 20:22
3

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!

uzumas
  • 219
  • 1
  • 3
  • 7
0

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.