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.
3 Answers
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.

- 16,185
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!

- 219
- 1
- 3
- 7
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.

- 21
-
3but beware: as Greg points out, it is a quick but very dirty way. The good thing is.. it works. – Mahesh Apr 16 '12 at 05:40
-
I did a similar thing and it worked great: sudo apt-get purge gedit ed nano – jettero Apr 21 '14 at 11:08
-
-
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 08 '21 at 02:21
.c
,.h
,.cpp
etc! I got my problem solved here – Shahbaz Nov 01 '11 at 13:30sed -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