Saturday, May 4, 2024
43
rated 0 times [  43] [ 0]  / answers: 1 / hits: 27996  / 3 Years ago, mon, may 3, 2021, 10:20:43

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.


More From » command-line

 Answers
3

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:



[Desktop Entry]
Categories=;
Comment=Edit file in Vim
Exec=vim %f
GenericName=Text Editor
Hidden=false
Icon=vim
Name=Vim
Terminal=true
Type=Application
Version=1.0


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.


[#40811] Monday, May 3, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
chilgirlguid

Total Points: 123
Total Questions: 114
Total Answers: 121

Location: Macau
Member since Mon, Nov 16, 2020
4 Years ago
;