I use Vim on every distro for text editing, so I like to make sure that it is the Default text editor both in the Terminal and the Gui Desktop.
How to set Vim as default system wide, issue the command and choose Vim:
sudo update-alternatives –config editor
Which gives me this output:
You can see that Nano is currently set as default so I choose number 3 to set vim.basic
Selection Path Priority Status
* 0 /bin/nano 40 auto mode
1 /bin/ed -100 manual mode
2 /bin/nano 40 manual mode
3 /usr/bin/vim.basic 30 manual mode
4 /usr/bin/vim.tiny 10 manual mode
Setting the Terminal Vim as the Gui Text Editor:
Most desktop environments and distros have one of the top 3 terminals and text editors set as default, so we are going to create a little Bash script to tell the system to use our terminal Vim text editor instead of the system’s default Gui Editor:
D/E TERM EDITOR
Xfce xfce4-terminal Mousepad
Gnome gnome-terminal Gedit
Kde konsole Kate
1. Create the script:
2. Add this with your particular terminal:
Leave it as it is for Gnome, Xfce, Xterm, etc but remove the quotes “” from [vim $ARGS] for konsole.
Thanks to penguiniator for pointing that out in the comments 🙂
gnome-terminal -e “vim $ARGS”
3. Save and Quit:
4. Make script executable:
chmod +x vim-gui
5. Copy script to your scripts directory (/home/USER/bin)
cp vim-gui /home/rich/bin/
6. Set it as the default editor from your desktop:
Open your file browser; Dolphin, Nautilus, Thunar etc, right click on any text file and select “Properties“.
Now look for the “Open With” option, and select “Add” or “Use Custom Command” and navigate to your vim-gui script in /home/USER/bin.
You can do this for any files you wish to open with Vim in the terminal by default.