When you use vim to edit a terminal, by default, the editing interface does not display line numbers, syntax high brightness display, smart indentation, and other functions. To better work in vim, you need to manually set a configuration file:. vimrc. When vim is started, the. vimrc file under the root directory of the current user will be automatically read. This file can contain some settings
When you use vim to edit a terminal, by default, the editing interface does not display line numbers, syntax high brightness display, smart indentation, and other functions. To better work in vim, you need to manually set a configuration file:. vimrc.
When vim is started. the vimrc file is automatically read, which can contain some settings or even scripts. the vimrc file is easy to create in the root directory of the current user, that is, the command to create is:
$ Vi ~ /. Vimrc
After setting
$: X or $ wq
Save and exit.
The following example shows the frequently used settings. for detailed settings, see references:
"Comments rows starting with double quotation marks, the same below
"Remove the annoying vi consistency mode and avoid bugs and limitations in earlier versions.
Set nocompatible
"Show row number
Set number
"Detection file type
Filetype on
"Black is used for background
Set background = dark
"Syntax high brightness display
Syntax on
"The following two lines are useful in the format when writing code;
"In the first line, vim uses automatic start, that is, to apply the format of the current row to the next line;
"The second line, based on the preceding setup format, intelligently selects the setup method.
"Writing is very useful.
Set autoindent
Set smartindent
"The tab key of the first line is set to 4 spaces, and the second line is set to use 4 spaces when lines are staggered.
Set tabstop = 4
Set shiftwidth = 4
"Set the matching mode, similar to the right brace that will be matched when a left brace is entered.
Set showmatch
"The status line at the cursor position is displayed in the lower right corner during editing.
Set ruler
"By default, matching is displayed in high brightness. this setting turns off the highlighted display.
Set nohls
"It is very convenient to query. to search for the book word, when/B is entered, the first
"A word starting with B. When it is input to/bo, it will automatically find the word starting with the first bo, according
"And so on, you can use this setting to quickly find the answer.
"Don't forget to press enter
Set incsearch
"F5 compiles and runs C programs, F6 compiles and runs C ++ programs
"Please note that an error will be reported when the following code is used in windows.
"Remove the./characters.
"C compilation and running
Map : Call CompileRunGcc ()
Func! CompileRunGcc ()
Exec "w"
Exec "! Gcc %-o % <"
Exec "! ./% <"
Endfunc
"C ++ compilation and running
Map : Call CompileRunGpp ()
Func! CompileRunGpp ()
Exec "w"
Exec "! G ++ %-o % <"
Exec "! ./% <"
Endfunc