VI editor configuration code highlighting

The biggest difference between the VI editor and the VIM editor under Linux is that the VIM editor has code highlighting.

There is no code highlighting in the VI editor.

But when I am used to code highlighting, I suddenly saw a piece of code, which made me feel a little uncomfortable.

So, I want to configure the code highlighting of the VI.

In fact, the code highlighting of the VI editor is to open VIM when opening the VI editor. To be honest, it's still a bit rogue.

1: Check if the VIM editor is installed on your server.

Centos installation command:

yum install -y vim

2: Global configuration VI editor code highlighting

(1): Use the VI editor to open the /etc/profile file.

vi /etc/profile

(2): Add the following code in /etc/profile

alias vi=vim

(3) Restart the server or use the following command to make the changes take effect

source /etc/profile

3: Set VI editor code highlighting for specific users

In theory, after configuring global users, there is no need to configure specific users.

However, sometimes it cannot be configured for global users, but needs to be configured for individual users.

(1): Open the .bashrc file in the user's home directory

 vi /home/用户名 /.bashrc

(2): Add code under /home/username/.bashrc

alias vi=vim

(3) Restart the server or use the following command to make the changes take effect

source /home/linuxidc/.bashrc

4: Display line number and indentation

Modify the /etc/vimrc file and add the following two lines of setting commands at the end of the file:

set nu
set tabstop=4

Restart the VI editor. It's easy to use.

Have a good suggestion, please enter your comment below.

Welcome to personal blog
https://guanchao.site

Welcome to the Mini Program:
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_39708228/article/details/113029371