Haha, small series again, today, small series will introduce you to the powerful Vim editor on Linux. First of all, let us introduce what is the Vim editor. The Vim editor, also known as a text editor, does not require a graphical interface to work with Vim, but is edited by using keyboard commands, which is a favorite editor for many programmers because of its high efficiency.
Three main modes of VIM:
Command mode: The default mode, control the screen cursor movement, character, word or line deletion, cut copy text and so on.
Insert mode: Only in the insert mode, you can enter the text, press the "ESC" key to return to the command line mode.
Extended Command mode: Save or exit the file, or set the editing environment, such as setting the line number, matching the parentheses in pairs, and so on.
Mode conversion
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/9D/CF/wKiom1mGvv_ACzpZAAA3PbnkQew117.png "/>
I:insert, enter at the cursor position
I: Enter at the beginning of the line where the current cursor is located.
A:append, enter after the cursor is located.
A: Enter at the end of the line at which the current cursor is located.
O: Opens a new line below the line where the current cursor is located.
O: Opens a new line above the line where the current cursor is located.
Command mode cursor Jump:
Between characters Jump: H: Left L: Right J: Next K: Up
Current page Jump: H: Top M: Page Middle row L: Bottom of page
Start line End Jump: ^: Jump to the first non-whitespace character at the beginning of a row 0: Jump to beginning of line $: jump to end
Move between rows: G: Last line GG or 1G: First row
Command mode Flip screen operation
CTRL+F: Flip a screen to the end of the file
CTRL+F: Flip a screen to the file header
Ctrl+f: Turn half screen at the end of the file
Ctrl+f: Turn half screen at the end of the file
Command mode operation:
Character editing
X: Delete the character at the cursor
#x: Delete the # characters at the beginning of the cursor
XP: Swap the position of the character where the cursor is located and the character after it
~: Convert Case
J: Remove line breaks after the current line
Replace command
R: the character at which the cursor is replaced
R: Switch to replace mode
Delete command
D: Delete command, can be combined with the cursor jump character, to achieve range deletion
d$: Delete to end of line
d^: Delete to non-empty header
D0: Delete to the beginning of the line
DD: Delete the line where the cursor is located
#dd: Multiline Delete (#代表数字)
D: Always delete from the current cursor position to the end of the line, leaving blank lines, equivalent to d$
Copy command
Y: Copy, behaves similar to D command
YY: Copying rows
#yy: Copy multirow (#代表数字)
Paste command
P: If the buffer is an entire row, paste the current cursor below the row, or paste it at the end of the current cursor.
P: If the buffer is an entire row, the current cursor is pasted above the row, otherwise, it is pasted to the front of the current cursor position.
Change command
C: Switch to insert mode after modification
CC: Delete the current line and enter new content
C: Delete the current cursor to the end of the line and switch to insert mode
Undo Changes
U: Undo Recent Changes
#u: Undo Multiple Changes (#代表数字)
U: Undo all changes to this row after the cursor falls on this line
Press Ctrl-r to redo the last undo change
. : Repeats the previous action
N.: Repeats the previous action n times
Extended Command mode: Address delimitation
#具体第 # line.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/9D/CE/wKioL1mGvv-Bf29DAAFq2PJheIM453.png "/>
$ last line
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/9D/CF/wKiom1mGvwDy3G7OAAB7w2Rz3V0943.png "/>
/pat1/,/pat2/begins with the first line that is matched to the pat1 pattern, until the end of the line that is first matched to the PAT2.
Usage: followed by an edit command such as D, Y, etc.
W File: Saves the range of rows to the specified file.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/9D/CE/wKioL1mGvwDSR-IIAAEbFki2Vck713.png "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/9D/CF/wKiom1mGvwGjxAXnAABwkJX2Kic855.png "/>
R file inserts all content from the specified file at the specified location
650) this.width=650; "align=" left "src=" Http://s3.51cto.com/wyfs02/M01/9D/CE/wKioL1mGvwHysyqEAAD0KGrKYas760.png "/ >
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/9D/CF/wKiom1mGvwKgKh_gAAEoeTJ0Xwk158.png "/>
Extended mode command: Find
/pattern: Looks at the end of the file from the current cursor location
? PATTERN: Finds the file header from the current cursor location
N: Same direction as command
N: Opposite direction of command
Extended Command mode: Find and replace
S: Complete the Find and replace operation in extended mode
Format: s/What to look for/replace with content/modifiers (note: To implement full-text lookups, you need to precede the%):
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/9D/CE/wKioL1mGvwKwbSpqAABvttFw4s4591.png "/>
(by default, each row replaces only the first occurrence)
G: Global Substitution
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/9D/CF/wKiom1mGvwOBq5xWAABeQQD8zgc194.png "/>
GC: Global substitution, ask before each replacement.
Find the delimiter in the substitution/replaceable to be another character.
The function of Vim is really powerful, here, small series is not listed, if you are interested, you can view vim built-in Help. 650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/9D/CE/wKioL1mGvwOjD1bmAAFoRa3xr0o181.png "/>
A powerful VIM editor