The first step, install vim command: sudo apt-get install vim
The second step, change the vim configuration file etc/vim command to:
(1) cd /etc/vim
(2) sudo gedit vimrc
The third step is to insert the following content in the last line of vimrc
syntax on
set tabstop=4set shiftwidth=4set autoindent
set cindent
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
set nu
set softtabstop=4
The fourth step is over after saving, and then opening the .c file with vim will show the effect of highlighting and different syntax colors.
/Explain the meaning of the above settings/
syntax on //Set syntax highlighting set tabstop=4//Set the tab width to 4 set softtabstop=4//Set the soft tab width to 4 set shiftwidth=4//Set the number of spaces for indentation to 4 set autoindent//Set automatic indentation set cindent//Set to use C/C++Language automatic indentation set nu//Display the line number of the text on the left
Supplement: How to set the line number in Ubuntu vi
sudo vi /etc/vim/vimrc
Open the vimrc file, add set nu at the bottom, save and add the line number, set autoindent is automatic line wrapping
to sum up
The above is a detailed explanation of the steps for ubuntu16.04 to automatically set the line number introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message, and the editor will reply to you in time. Thank you very much for your support to the ZaLou.Cn website!
Recommended Posts