How can I change the default text editor from gedit to vim? When I click on a text file, I want it to open in vim under the terminal instead of gedit.
How can I change the default text editor from gedit to vim? When I click on a text file, I want it to open in vim under the terminal instead of gedit.
You don't say how you are clicking on this file, so I will explain a way to do it in Gnome from Nautilus. It should work in other cases, I believe.
First, to get Vim (or any app) into the "open with other application" list, you need to create a .desktop file in
~/.local/share/applications
with a line in it like this:Exec=<command> %f
. I just made one called vim.desktop with these lines:This made "Vim" appear in the list of possible apps when I right-clicked in Nautilus, and opened the file as expected.
Let me know if there are any problems.
Open
defaults.list
Replace
with
Save and close.
For more details and screenshot check this answer: How do I stop gedit from opening anything?
Save this as
~/.local/share/applications/vim.desktop
:Then in Nautilus right-click on a text file, choose "Properties" and go to "Open with". If vim isn't shown here click "Show other applications". Select vim and click "Set as default".
The problem with the
vim.desktop
approach is that each time it will open a new terminal window, instead of using an existing vim instance. This is probably not what you want, but I don't think there's any way around it.The next best thing is using
gvim
, which is a GUI app, instead of a terminal app.Pure command line based method: