In the Linux environment under the centos system, set the line number and code highlighting of vi and vim

1. Learning objectives

It seems to have been set once before, and then I found that it won’t work again. I searched it on Baidu and Google. This time I recorded it. It will save time next time.

Let's take a look at the effect first, before it is useless: After
Insert picture description here
setting the number of lines and highlighting, the commented code and the uncommented code are clear at a glance, which is very convenient.
Insert picture description here

2. Setting steps:

1. Vim sets the number of lines and highlights

syntax on # highlight
set nu # display the number of lines

Do not bring any #and 中文otherwise error:

vi /etc/vimrc

# 最后一行加入,不要辅助这行注释

syntax on
set nu

2. vi sets the number of lines and highlights

After the vim setting number above:

vi /etc/bashrc
# 最后一行加入
alias vi=vim

Restart using source/etc/bashrc

source /etc/bashrc

After the execution is completed, vim and vi will be highlighted when editing, which is very convenient.

Guess you like

Origin blog.csdn.net/weixin_42081389/article/details/108535173
Recommended