in the Linux system, we often use the VI or VIM command to manipulate the text, sometimes, our script file error, will throw a line number of exceptions, and then we follow the prompts, reopen, our source to view, and this time, If your vim is not set to display line number function, we look for the problem of the line of code, it is very inconvenient, do not know if you have encountered this situation.
The solution is as follows:
(1) The Cat-n command is able to display the line number of the text at once, which is easy for us to observe, but it doesn't work in the editing state.
(2) Configure the line number function of vim so that you can quickly locate line numbers at any time, in the editing state.
Scattered cents, we recommend that you use the second method, the following look at the specific configuration method;
(1) root user, directly compile the/ETC/VIMRC file, add the following two lines to the end of the file set command:
Java code
- #显示行号
- Set Nu
- #设置缩进
- Set tabstop=4
(2) Non-root user, directly edit vi vimrc file, add command and (1) Like, save, exit, we again use the VI command, to edit the file, will show the line number, examples are as follows:
Java code
- [Search@dnode1 ~]$ VI Word
- 1 I am Hadoop
- 2 I am Hadoop
- 3 I am lucene
- 4 I am hbase
- 5 I am hive
- 6 I am hive sql
- 7 I am pig
How to set Vim's permanent display line number function under CentOS?