VI Editor: Full-screen text editor
Vi:visual interface, visual interface;
Vim:vi improved
Vim has more new features relative to VI:
1. Syntax coloring display;
2. More orders;
3. Historical records;
Vi: Patterned text editor
mode:
Edit mode (command mode), default working mode
Insert mode (input mode), free editing of text information; "Insert" mark in the lower left corner;
Ex mode (last line mode), for the editor's own properties and function settings, you can also edit the text;
Other auxiliary modes:
Replacement mode: The input information directly replaces the content of the cursor position;
Visualization mode:
Vi/vim operation:
First, open the Vi/vim operator interface;
1.vi/vim order;
2.vimfile:
1) file exists, directly using the VIM editor to open it, the default is to place the cursor in the file's starting file location, namely: the first character of the first line;
2) file does not exist, it is opened directly as a new file, if you execute the Save command, the files will be written to disk, if not saved, the file will disappear.
3.vim+# file:
When the specified file is opened, the cursor is positioned directly at the beginning of the # line of the file, and if the given number is larger than the number of rows in the file, the cursor stays at the beginning of the last line;
4.vim+ file:
When you open the specified file, position the cursor directly at the beginning of the last line of the file.
5.vim+/pattern/:
When you open the specified file, position the cursor at the beginning of the line that was first matched to the pattern;
Two. Close the operating interface of the Vi/vim;
Operations in the EX mode:
: Q
Directly close the Vim editor, do not save the modified content;
: q!
Close the Vim editor directly, forcing the exit without saving the modified content;
: Wq
Save the modified content and close the Vim editor;
: wq!
Force save for files that do not have permission to change, and force the Vim editor to close after forcing save;
Operation in edit mode:
ZZ: Save and close the vim editor;
ZQ: Do not save the modified content, directly close the vim editor;
Three. In Vim's edit mode, the cursor moves:
cursor Movement in edit mode:
1. Character movement:
1) left ARROW or RIGHT ARROW
2) H: The cursor moves to the right; Move Word by Word:
W: Move the cursor to the beginning of the next word;
E: Move the cursor to the end of the current word or the next word;
B: Move the cursor to the first word;
3. Inline cursor Jump
0: Absolute start of the line
^: Relative beginning
$: absolute end of line
4. Between the lines Jump
1) up ARROW or down arrow;
2) J: Move down one line; K: Move up one line;
3) #G: Move the cursor directly to the beginning of line #;
4) G: Move the cursor directly to the last line of the document;
5) GG: Move the cursor directly to the first line of the document;
Ex mode cursor movement:
: #: Move the cursor directly to the beginning of line #;
: L: Move the cursor directly to the beginning of the first line of the document;
: Move the cursor directly to the beginning of the last line of the document;
Four. Page turn
PageDown or pageup can be turned on;
^+f: Scroll down one page, turn one page forward, equivalent to PgDn;
^+b: Turn up one page, turn back one page, equivalent to PgUp;
^+d: Turn half page down;
^+ U: Turn up half a page;
five. Delete character;
action in edit mode
1. Character deletion:
x: Delete the characters at the cursor location,
x: Delete one character to the left of the cursor position,
2. Delete all the content that passes through the cursor;
D: Removes all characters passed during the cursor movement;
Dh, dl, dj, dk, dArrow, dw, de, db, dG, dgg, d0, d$, d^
Dd: delete the line where the current cursor is located;
Operation in ex mode:
:d: delete the line where the cursor is located; equivalent to: .d; where "." refers to the current line;
:#d: Delete the ## line;
:m,nd: delete all lines starting from the mth line and ending in the middle of the nth line;
:m,+nd: deletes the content starting from the mth line and the following n lines;
:.,+nd: deletes the content starting from the current cursor line and the following n lines;
:.,$d: Delete everything from the current cursor line to the end of the document;
Note: In the operation of vim, all delete operations mean shearing at the same time;
Six. Copy commands
Actions in edit mode:
Y: Copy all the content that passes through the cursor during movement;
Yh,yl,yj,yk,yArrow,yw,ye...
Yy: copy the line where the current cursor is located;
Replication in ex mode:
:y: copy the line where the cursor is located; equivalent to: .d; where "." refers to the current line;
:#y: Copy the ## line;
:m,ny: copy all lines starting from the mth line to the end of the nth line;
:m,+ny: copy the content starting from the mth line and the following n lines;
:.,+ny: copy the content starting from the current cursor line and the following n lines;
:.,$y: Copy everything from the current cursor line to the end of the document;
Seven. Paste command:
operation in edit mode
P (lower); If you are copying or cutting within a row, paste is done on the right side of the cursor, and if it is a multiline copy or cut operation, paste at the bottom of the cursor;
P (Upper): If it is a copy or cut operation within a row, Paste on the right side of the cursor, or in the case of multi-line copy or cut operations, paste on top of the cursor;
Ex mode:
: P
Eight. Mode toggle:
Edit mode (Command mode) is called the VI Editor's basic working mode; a broker that switches between all other modes
1. Edit mode --> ex mode:
":": indicates entering the ex mode and completing the execution of the command;
"/" or "?": Start the match search function in ex mode;
/: The default is the top-down search order;
? : The default is the bottom-up search order;
The n and N commands jump between the matching keywords:
n: sequential search
N: reverse search
2.ex mode --> edit mode:
Esc
Enter
Backspace
3. Edit mode --> input mode (insert mode):
i, I, a, A, o, O, s, S, C, cc
i: Start input on the left side of the cursor position;
I: Start typing at the beginning of the line;
a: Start inserting on the right side of the cursor position;
A: Start typing at the end of the line;
o: insert a new line below the current cursor line;
O: Insert a new line above the current cursor line;
s: delete the character at the cursor position and start input on the left side of the cursor;
S: delete the line where the cursor is located, and start input at the beginning of the line;
C: delete the cursor position until the end of the line, and start input at the end of the line;
Cc: equivalent to S mode;
4. Input mode --> edit mode
Esc
5. Edit mode --> replacement mode
R: enter the replacement mode
6. Replace mode --> edit mode
Esc
7. Edit mode --> visualization mode
v: rectangle selection according to characters;
V: Select a rectangle according to the unit of action;
note:
1) After the selection is completed, you can use the d command to delete, or you can use the y command to copy;
2) As soon as the selection is completed, it will return to the edit mode immediately;
Note: All other modes can only be switched to and from the edit mode: if the two non-edit modes attempt to switch, they must go through the edit mode.
Nine. Replacement mode:
R: The character that replaces the cursor position without entering the input mode;
10. Undo the command:
U: Undo the operation in the current line;
U: Undo the previous edit operation;
^+r: Undo the last undo operation;
11. Repeat the previous edit operation;
.
12. Open multi-document editing;
1.vimfile1 file2 file3 ...
: Next to view or edit the latter document
: prev Viewing or editing a previous document
: First to view or edit one document
: Last view or edit Final Document
2.vim-o | -O file1 file2 file3..
-o: Open multiple windows horizontally
^+w,uparrow | down arrow;Switch between multiple windows;
-O: Open multiple windows vertically
^+w,leftarrow | right arrow; switch between multiple windows;
:qa: quit all
13. Common commands in the EX mode:
1. Display and cancel line numbering:
: Set Number (abbreviated: Set NU): Displays line numbering
: Set Nonumber (abbreviated: Set Nonu): Row numbering is canceled
2. Turn the sensitivity of character case on or off:
: Set ignorecase (Set IC)
: Set Noignorecase (set Noic)
3. Turn the Auto Indent feature on or off:
: Set Autoindent (abbreviated as: Set AI)
: Set Noautoindent (abbreviated as: Set Noai)
4. Turn syntax coloring on or off:
: Syntax on
: Syntax off
5. Turn on or off find highlighting
: Set Hlsearch
: Set Nohlsearch (abbreviated as: Nohl)
6. Save As:
: W/path/to/somewhere all Save As
: M,nw/path/to/somewhere Partial Save As
7. Read content directly from other files and add to current folder
: R/path/from/somefile
8 Interacting with the shell, invoking the shell command
:! Shell command
Basic usage of VIM editor