Linux Vi editor code highlighting and permanent display line number scheme

  

In linux, use vi to edit and modify the file configuration, there is no color display file content, especially some keywords can not be displayed in color, give us configuration service process Caused great inconvenience. [In fact, mainly vi itself does not have color, vim with color] The following gives a solution.

Vi Editor Code Highlight Settings

1. Check whether highlighting is enabled. Generally, it is enabled by default.

2, modify #vi /etc/bashrc Add

alias vi=vim

at the end and then wq save and exit.

This will automatically open vim when typing vi in ​​the shell (vim is short for vi improve)

3, modify #vi /etc/vimrc Add "syntax" to the following statement On ”, after restarting vi or restarting the computer, you can turn on the highlight.

bash/shell Code Copy Content to Clipboard

if &t_Co > 2 | |  Has("gui_running")

syntax on

set hlsearch

endif

Note: If you have one, you don't have to add it.

In Linux, we often use the vi or vim command to manipulate the text. Sometimes, our script file has an error, it will throw an exception with a line number, and then we will follow the prompts. Re-open, our source code to view, and at this time, if your vim does not set the display line number function, we find the code of the line of the problem, it is very inconvenient.

Set the Vim editor to display the line number permanently

Modify the /etc/vimrc file and add the following two lines to the end of the file:

Copy Code

The code is as follows:

set nu

set tabstop=4

Note: set nu #display line number set tabstop=4 #设置缩进

Copyright © Windows knowledge All Rights Reserved