Viim Editor
Text: Plain text, ASCII test;
Type of text editing:
Line Editor: SED
Full Screen Editor: Nano,vi
Other editors:
Gedit a simple graphical editor
Gvim a graphical version of the VIM editor
I. Several ways to open a file
Command format:
vim [options] [Files]
Common options:
+#: After opening the file, just leave the cursor at the beginning of line #
+/pattern: After opening the file, let the cursor be in the first line to match the PATTERN
The beginning of the line that Patterb matches to
Vim+file Open file directly, the cursor is in the last line
Vim-b file binary mode open files
vim-d file1 file2 ... Compare multiple Files
Vim-m file to open files in read-only mode
Ex file or vim-e directly into command line mode
Two. 2 modes to close file methods:
Extended Command mode:
: Q exit
: q! Force exit, do not save the previous edit operation
: Wq Save and exit
: X Save and exit
General mode:
ZZ: Save exit
ZQ: Do not save exit
Three. Model details
Three main modes:
General mode: Move cursor, cut/paste text
Edit mode: Modify text
Command mode: Save exit, etc.
I. GENERAL mode
General mode available button description, cursor movement, copy and paste, find replace
(1) Cursor movement
Jump between characters:
H: Left L: Right J: Lower K: Upper (same as left and Next arrow functions)
Support digital jump: #{h|j|k|l} jumps the number of characters specified by the # number
Move between words: You can use the W,e,b key to move
W: The next word in the first word
E: The current word or the beginning of the next word
B: The current word or the first word
#{w|e|b}
The screen moves up and down
Ctrl+f screen Move down one page equals PageDown button (Common)
Ctrl+b screen Move down one page equals PageUp button (Common)
Ctrl+d screen Move Down half page
Ctrl+b screen Move up half page
H the first character of the line that the cursor moves to the top of the screen
The first character of the line that the M cursor moves to the center of the screen
L the first character of the line that the cursor moves to the bottom of the screen
G move to the last line of this file (common)
NG moves to the nth row of this file
GG moves to the first line of this file equivalent to 1G
N[enter] n is a number, the cursor moves down n rows
Move between rows
0 Number "0" moves to the first character in this line (common)
$ move to the last face character of this line (common)
(2) Find and replace
/word looking down for a word named word
Word looks up for a string named word
N Repeat the previous find operation
n and n exactly opposite "reverse" for the previous find operation
(3) Delete, copy, paste
X,x x Remove one character x backward and delete one character forward
NX N is a number that removes n characters backwards
DD Delete the entire line where the cursor is located (common)
NDD N is the number of rows where the cursor is deleted.
D1G Delete all data from the first row of the cursor
DG deletes all data from the last row of the cursor
d$ Delete all data from the last character of the line where the cursor is located
D0 Delete all data between the first character of the line where the cursor is located
YY the line where the cursor is copied (common)
Nyy N is a number, copying the row of the cursor to the n rows down
y1g Copy all data from the row to the first row of the cursor
YG copy data from the row to the last row of the cursor
y0 Copy all characters from the line to the beginning of the cursor
y$ Copy all characters from the line of the cursor to the end of the line
PPp Pastes the copied data one line below the cursor, and p is pasted to the previous line
J combines data from the row of the cursor and the next row into the same row
C repeatedly delete multiple data, for example down delete 10 rows down
CC Delete Current line and enter new content
U Undo Previous action (Common)
Ctrl+r Redo last Action (common)
Two. Edit mode
General mode switch to edit mode available button description
I,i into insert mode I is inserted from the current cursor, I is inserted at the first non-space character where the current row is located (common)
A,a enters insert mode A to insert from the next character where the cursor is currently located, a is inserted from the last character in the line where the cursor is located
O,o into insert mode O is the letter O insert a new line at the next line where the cursor is currently located o to insert a new row in the previous row at the current cursor (common)
R,r into insert mode R will only replace the one character where the cursor is, and R will always replace the text of the cursor until the ESC key is pressed (common)
Three. command-line mode
: W writes the edited data to the hard drive file (common)
: w! Force the file to be written if the file is read-only
: Q leave VI (common)
: q! If you have modified the file and do not want to save, use! Force to leave
: Wq left after saving
ZZ If the file is not changed, do not save the left, if the file is changed, save left
: W[filename] Save the edited file to another file
: R[filename] In the edited data, read into the data of another file, the "filename" of the file content is added to the cursor line after the
: N1,n2 W[filename] Save the contents of N1 to N2 as filename for this file
:!command temporarily leaves VI to command-line mode to display results
Command-line mode: Valid for the current VIM process
(1) Line number
: Set NU Displays the line number, after which the line number of the row is displayed in each row
: Set Nonu is the opposite of Set Nu, to cancel line number
(2) pairs of parentheses match
: Set Showmatch Match
: Set NOSM Cancel
(3) Auto Indent
: Set AI Enable
: Set Noai disabled
(4) Highlight Search
: Set Hlsearch
: Set Nohlsearch
(5) syntax highlighting
: Syntax on enabled
: Syntax off disable
(6) Case of ignoring characters
: Set IC Enabled
: Set Noic does not ignore
(7) file format
: Fileformat+unix Enabled
: Fileformat=dos
(8) Set text width
: Set textwidth=65 (VIM only)
: Set wrapmargin=15
This article from "zhang1003995416" blog, declined reprint!
Key instructions for the VIM editor