Played three years of Linux, the most commonly used vim compiler some of the use of skills to organize the next share to everyone.
The text editor under Linux vi=visual:
Vim (vi improved) literally means an upgraded version of VI.
The VI Modular compiler is divided into three modes:
Input mode
Command mode (edit mode)
Last-line mode: Enter a colon into the command mode
VI File open files
VI +n file opens files and displays in n rows
Command mode:
A: Enter at the back of the cursor
A: Input at the end of A row
I: Enter at cursor
I: Enter at the beginning of the line
O: Another new line input
O: Enter the new line above
End mode
: Q exit
: q! Force exit
: Wq Save Exit
Cursor moves by character
H (left) J (down) K (UP) L (right)
Cursor moves by word
W quickly jumps to the beginning of the next word
E quickly jumps to the ending of a word, backwards
B quickly jump to the beginning of a word, forward
^ Jump to the beginning of a non-blank place
0 jump to the beginning of the line
$ jump to end of line
NG jumps to n rows
G jumps to the end of the file
: n jumps to n rows
Realize Flip Screen
Ctrl+f Front Flip Screen
Ctrl+b Turn back the screen
Ctrl+d Turn down half screen
Ctrl+u turn up half screen
Edit operation
x Delete the character of the cursor
NX removes n characters from the cursor
DD deletes the cursor in the row
NDD Delete cursor up n rows
DW Delete Word with cursor
d^ Delete cursor at beginning of line
DG deletes content after the cursor line
Last-row mode delete
: Addr1,addr2d such as:
: 1,8d Delete 1 to 8 rows
: 8d three 8th row
:. When moving forward
: $ last line
:., $-1d Delete the current line to the second penultimate line
Overwrite action
CC: Delete the cursor line and convert to input mode
NCC: Remove n rows from the cursor line and convert to input mode
Like C$,c0,cw,ncw,ce,nce, for example.
Copy
YY copy when moving forward
Nyy Copy current n rows
y$ copy cursor to end of file
y0 copy cursor to beginning of line
Paste
P: Copy below the current line
P: Copy the top of the current line
Undone actions (files that have not been saved)
U undo last operation, up to 50 consecutive steps undone
U undo operation in the file cache
Undo the Last revocation
Ctrl+r
Repeat the last action
.
Visualization mode
Enter visualization mode
V by row selection
V Select by character
Open multiple Files
VI FILE1 FILE2 FILE3 ....
The default cursor opens the first
: Next Next file
: Previ Previous file
: First File
: Last File
Split screen Display
Vim-o FILE1 FILE2 up and down split screen
CTRK +w 2 times
Vim-o FILE1 FILE2 left and right split screen
CTRK +w 2 times
Same file
Ctrl+w,s Horizontal Split
Ctrl+w,v Vertical Split
Set the working characteristics of vim
: Set NU Displays the number of rows
: Set Nonu suppress row count
: Set Al Auto Indent
: Set noal Cancel Auto Indent
Syntax highlighting
: Syntax on open syntax highlighting
: Syntax off to cancel syntax highlighting
Vim has two configuration files
/ETC/VIMRC Global Configuration
/home directory/.VIMRC User Configuration
Search for characters
/search from cursor to tail
? Search from cursor to header
Find and replace
: s
: addr1,addr2s/pattern/string/g
:% #PATTERN/string/i
I ignore case
G Global, replacing the entire row
% full Text search, full text replacement
In addition to/, you can also use the $ #等符号
Original-linux compiler VI, VIM use tips