After a period of using Linux, I also got used to and really like some tools. One of the most important tools I use is the editor Vim.
Many configuration files use Vi instead of Vim, and you can run the vi command. However, the vi command is a link to vim.
Many Linux tools use emulated editors or just Nano, Emacs, or Vim. Some other tools allow users to link to their favorite editor. The two examples that influenced me the most were Bash command-line editing, which defaults to Emacs, and the Alpine text-mode email client, which defaults to the Pico editor. In fact, the Pico editor was developed explicitly for use in the Pine email client, which was the forerunner of Alpine.
Not all programs that use external editors are configurable. Some just use the editor specified by the developer. For configurable apps, we have different methods for choosing your preferred editor.
Linux command line editing
Besides editing text files, the thing I edit the most is Bash shell. The default Bash editor is Emacs. Although I used Emacs, I prefer Vim. So I switched the default Bash command line editor from Emacs to Vim, which made me much more comfortable.
There are several ways to configure Bash. You can use a local configuration file such as /home/yourhomedirectory/.bashrc, which changes the defaults only for your user account and not for other users on the same system. I like to make these kinds of changes system-wide, which basically means the personal account and the root account. In this second case, you can create your own configuration file and place it in the /etc/profile.d directory.
I added a file called myBashConfig.sh to /etc/profile.d. There are files for all installed shells in the /etc/profile.d directory. During terminal launch, each shell only reads files intended for it based on the file type. For example, the Bash shell only reads files with the .sh extension.
<SNIP> alias vim='vim -c "colorscheme desert" ' # Set vi for bash editing mode set -o vi # Set vi as the default editor for all apps that check this EDITOR=vi <SNIP>
Current set -o vi used to set Vi as the default editor. The -o option on this set command defines vi as the editor. You need to close any running Bash sessions and open a new one for this change to take effect.
You can now use all your familiar Vim editing commands, including cursor movements. Just press the Escape key to enter Vim edit mode. I especially like the ability to use b multiple times to move the cursor back multiple words.
Make Vim default for other programs
Several Linux command line tools and programs check environment variables $EDITOR to determine which editor to use. You can check the current value of this variable yourself with the following command:
# echo $EDITOR /usr/bin/nano #
By default, Fedora programs check the environment variable $EDITOR and use the Nano editor. Add line EDITOR = vi to
myBashConfig.shchange default to Vi editor (Vim). Not all command-line programs that use an external editor check this environment variable.
I prefer Vim to other editors and these changes will make other programs use the VIM editor by default. Some programs use environment variables $EDITOR so you only need to make that change once.
The ability to choose your preferred external editor is quite consistent with the tenet of Unix Philosophy, “Every program should do one thing and do it well.” Why write another editor when there are some perfectly good ones out there? And it also fits right in with the Linux philosophy, “Use your favorite editor.”
Of course, you can change your default editor to Nano, Pico, EMACS, or whatever else you like.