• 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

Script backup database and website on telegram
Network

Script backup database and website on telegram

May 2, 2025
Create 64GB RAM 16 core for free on Google IDX
Network

Create 64GB RAM 16 core for free on Google IDX

April 13, 2025
What is VPS running Vietnamese software? What is the reason for installing Vietnamese software on VPS?
Network

What is VPS running Vietnamese software? What is the reason for installing Vietnamese software on VPS?

February 17, 2025
Create Ronin wallet to play pixels on VPS Windows
Network

Create Ronin wallet to play pixels on VPS Windows

February 17, 2025
What is Proxy Gradient Network? Instructions for using Proxy to suspend multiple Gradient accounts
Network

What is Proxy Gradient Network? Instructions for using Proxy to suspend multiple Gradient accounts

December 26, 2024
How to buy a .news domain for free for 0 VND at Namecheap
Network

How to buy a .news domain for free for 0 VND at Namecheap

December 22, 2024
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

Discover Supermix – Smart playlist on YouTube Music

Discover Supermix – Smart playlist on YouTube Music

May 20, 2025
The 10 best Torrent websites today – 100% still operate

The 10 best Torrent websites today – 100% still operate

May 20, 2025
Share Code Shop Selling Acc game extremely lightweight written in bootstrap

Share Code Shop Selling Acc game extremely lightweight written in bootstrap

May 19, 2025
Instructions for downloading all photos and story from Instagram

Instructions for downloading all photos and story from Instagram

May 19, 2025
Discover Supermix – Smart playlist on YouTube Music

Discover Supermix – Smart playlist on YouTube Music

May 20, 2025
The 10 best Torrent websites today – 100% still operate

The 10 best Torrent websites today – 100% still operate

May 20, 2025
Share Code Shop Selling Acc game extremely lightweight written in bootstrap

Share Code Shop Selling Acc game extremely lightweight written in bootstrap

May 19, 2025
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

Discover Supermix – Smart playlist on YouTube Music

Discover Supermix – Smart playlist on YouTube Music

May 20, 2025
The 10 best Torrent websites today – 100% still operate

The 10 best Torrent websites today – 100% still operate

May 20, 2025
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí SHBET bongdaso

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí SHBET bongdaso