Reprinted: https://blog.csdn.net/alex_15/article/details/63267539
Open the configuration file from the terminal:
vim ~/.vimrc
- 1
Add the following code:
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
set cindent
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
set nu
set ruler
set hlsearch
set backspace=2
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
The meanings are as follows:
1. Set the (soft) tab width to 4
set tabstop=4
set softtabstop=4
2. Set the number of indented spaces to 4
set shiftwidth=4
3. Set the automatic indent: the indentation of each line The value is equal to the previous line; use noautoindent to cancel the setting:
set autoindent
4. Use the automatic indentation method of C/C++ language
set cindent
5. Set the specific indentation method of C/C++ language (take my windows style as an example):
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
6. Display the line number
set nu
7. Display the ruler
set ruler
8. Highlight the search content
set hlsearch
9. Can delete any value
set backspace=2
10. Finally, there is a color scheme that can be used like Sublime Text:
download "monokai.vim" online and put it in the colors folder under ~/.vim (no If so, create a new colors folder);
download link: https://github.com/tomasr/molokai/blob/master/colors/molokai.vim
Then add the following code to the ~/.vimrc file:
syntax enable
set background=dark
:colorscheme molokai
- 1
- 2
- 3
Save and exit!