• Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
AnonyViet - English Version
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
AnonyViet - English Version
No Result
View All Result

How to make Vim the default editor on Linux

AnonyViet by AnonyViet
January 24, 2023
in Network
0

After a period of using Linux, I also got used to and really liked some tools. One of the most important tools I use is the editor Vim.

Join the channel Telegram of the AnonyViet 👉 Link 👈

How to make Vim the default editor on Linux

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 explicitly developed 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 only changes the defaults 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.

Conclusion

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.

The article achieved: 5/5 – (100 votes)

Tags: defaulteditorLinuxVim
Previous Post

Lesson 189: How to use the Frequency function in Excel

Next Post

How to see recalled messages on Messenger

AnonyViet

AnonyViet

Related Posts

Instructions on how to register a .co.uk domain name for free for 1 year
Network

Instructions on how to register a .co.uk domain name for free for 1 year

March 12, 2026
How to Setup Paperclip AI: Create a Company for AI Agent
Network

How to Setup Paperclip AI: Create a Company for AI Agent

March 12, 2026
Compilation of free and cheap APIs to run OpenClaw stably
Network

Compilation of free and cheap APIs to run OpenClaw stably

March 10, 2026
3 Services to Determine IP Location for Website (IP Geolocation API)
Network

3 Services to Determine IP Location for Website (IP Geolocation API)

March 10, 2026
How to buy a .STORE domain name for 1 USD (2026): Detailed instructions from A–Z
Network

How to buy a .STORE domain name for 1 USD (2026): Detailed instructions from A–Z

March 3, 2026
How to register OpenClaw to join Moltbook (social network for AI Agents)
Network

How to register OpenClaw to join Moltbook (social network for AI Agents)

February 7, 2026
Next Post
How to see recalled messages on Messenger

How to see recalled messages on Messenger

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

Windows can now run Linux applications

Windows can now run Linux applications

March 17, 2026
How to install extension to remind office workers to drink water

How to install extension to remind office workers to drink water

March 17, 2026
Why are iPhones and MacBooks still the number 1 “weapons” of the technology world?

Why are iPhones and MacBooks still the number 1 “weapons” of the technology world?

March 16, 2026
New features of Windows 10 21H1 are coming soon

New features of Windows 10 21H1 are coming soon

March 16, 2026
Windows can now run Linux applications

Windows can now run Linux applications

March 17, 2026
How to install extension to remind office workers to drink water

How to install extension to remind office workers to drink water

March 17, 2026
Why are iPhones and MacBooks still the number 1 “weapons” of the technology world?

Why are iPhones and MacBooks still the number 1 “weapons” of the technology world?

March 16, 2026
AnonyViet - English Version

AnonyViet

AnonyViet is a website share knowledge that you have never learned in school!

We are ready to welcome your comments, as well as your articles sent to AnonyViet.

Follow Us

Contact:

Email: anonyviet.com[@]gmail.com

Main Website: https://anonyviet.com

Recent News

Windows can now run Linux applications

Windows can now run Linux applications

March 17, 2026
How to install extension to remind office workers to drink water

How to install extension to remind office workers to drink water

March 17, 2026
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply