configuration file
Recall the last lesson
-
We learned about the status bar last time
- Expressed by escape
item
- control
item
Width method - take
item
Group approach - There is also a main switch
laststatus
- Expressed by escape
- But it’s troublesome to write a long paragraph to configure every time
- Can we write a configuration file so that
vim
How about automatic configuration every time?
configuration file
#First, open the original configuration file, ~ representing the user folder
vi ~/.vimrc
#You can find the writing method of the status bar with / statusline
~/.vimrc
- Can be found
~/.vimrc
namelyvi
ofconfiguration file
- If this configuration file cannot be found
vi
What will it look like? - try!
#Rename the original configuration file
mv ~/.vimrc ~/.vimrc_old
#Rewrite configuration file
vi ~/.vimrc
Write configuration file
-
After the configuration file is empty
- All configuration information is lost
- It doesn’t matter. Write from scratch
-
First, set a status bar in
~/.vimrc
Write two sentences insideset statusline=oeasy
set laststatus=2
- Note that not here
:
Yes
- Keep and exit
- Re edit
vi ~/.vimrc
- The status bar has been found to be effective
-
Update status bar
set statusline=%-040.40(%F%m%)%-030.30([%l,%c]%)%p%%
set laststatus=2
set ru nu sc
:h options
Query more practical switches
Various practical switches
set number
set numberset relativenumber
Show relative line numbersset cursorline
Highlight the current line where the cursor isset cursorcolumn
Highlight the current line where the cursor isset nocompatible
usevim
Mode, not withVi
compatiblesyntax on
Turn on syntax highlightingset showmode
The current mode is displayed at the bottomset showcmd
In command mode, the typing instructions are displayed at the bottomset mouse-=a
Pure keyboard operationset encoding=utf-8
Using UTF-8 encodingset autoread
After the hard disk file changes, it will be read automatically- Store these in
~/.vimrc
After that, these configurations will work automatically in the future - You can also go
github
search.vimrc
Find out more about configuration
Query switchoption
details
-
Help for querying a setting can be enclosed in single quotes
:h 'number'
Can findnumber
Related settings:h 'mouse'
Can findmouse
Related settings:h 'autoread'
Can findautoread
Related settings
Final setting
set statusline=%-040.40(%F%m%)%-030.30([%l,%c]%)%p%%
set laststatus=2
set ruler
set number
set showcmd
set nocompatible
set showcmd
set showmode
set history=100
- Can you spell out what they mean?
summary
-
Locate the location of the configuration file
~/.vimrc
- Understand various configuration switches
- Modify configuration file and apply
- But how is this color configured?
- Next time