text Editing
1. The cursor moves in the screen text can use the arrow keys, can also use the HJKL letter key.
H shift J down K move up L move right
2. To enter the Vim editor (from the command prompt line), enter: Vim file name < Enter >
3. To exit the VIM editor, please enter <Esc>: q! < Enter > Discard all changes.
or enter <Esc>: Wq < Enter > Save changes.
4. In normal mode, delete the character of the cursor position, press: X
5. To insert or add text, enter:
I input to insert text <Esc> insert text before cursor
A input to add text <Esc> add text after one line
Special Note: Pressing the <Esc> button will bring back to normal mode or undo a command that you do not want to enter or partially complete.
Delete and revoke
1. To delete from the current cursor to the next word, enter: DW
2. To delete from the current cursor to the end of the current line, enter: d$
3. To delete the entire row, enter: DD
4. To repeat an action, please add a number to the front of him: 2w
5. The format for modifying commands in normal mode is:
operator [NUMBER] Motion
which
Operator-operators, which represent things to do, such as D for deletion
[NUMBER]-numbers that can be appended, representing the number of times the action repeats
Motion-action, which represents the movement of the text on which it is manipulated
6. To move the cursor to the beginning of the line, press the number key: 0
7. To undo the previous operation, enter: U (lowercase u)
To undo the changes made on one line, enter: U (uppercase U)
To undo the previous Undo command and restore the previous operation results, enter: Ctrl-r
Replace
1. To reset the deleted text content, press the lowercase p key. The action can have the deleted text content after the cursor, if the last deleted
is an entire row, then the row is the next line that the cursor is on.
2. To replace the character that the cursor is in, enter the lowercase r key and the new character to substitute the original character.
3. The Change Class command allows you to move text from the current cursor position to the middle of the position indicated by the action.
4. Change the format of the class command:
c [NUMBER] Motion
Find
1.ctrl-g used to display the current cursor location and file status information
G is used to jump the cursor to the last line of the file
Type a line number first and then enter the capital letter G to move the cursor to the line that the favor represents.
GG represents the cursor jumping to the first line of the file
2. Enter/Then immediately follow a string to find the string in the currently edited document
Input? followed by a string that looks backwards in the currently edited document
Pressing the N key after a search is done repeats the last command to find the next matching string in the same direction;
or press N to reverse the search for the next string.
Ctrl-o takes you back to an older location ctrl-i takes you back to a newer location
3. If the cursor current position is (,), ",", {,}, press% to jump the cursor to the pair of parentheses
4. Replace the first string in a line with old as the new string, enter: S/old/new
Replace all strings in a row with old as the new string, enter: s/old/new/g
Replace the first string in two lines with old as the new string, enter: #, #s/old/new/g
Replace the first string in the file with the old string new, please enter:%s/old/new/g
When a full-text substitution is made, ask the user to confirm that each replacement needs to be added C flag:%S/OLD/NEW/GC
Summary
1. Enter lowercase o to open a new line below the cursor and into insert mode
Enter an uppercase O to open a new line above the cursor
2. Enter lowercase A To insert text after the cursor position
Enter an uppercase A to insert text after the end of the line in which the cursor is located
3. The e command allows you to move the cursor to the end of the word
4. Operator y copy text, p paste the previously copied text
5. Enter the uppercase R to enter the replacement mode until the [ESC] key is pressed back to normal mode
6. Enter: Set XXX to set XXX options.
' IC ' ignorecase ' ignores letter case when searching
' Is ' ' Incserach ' shows partial match when finding a phrase
' HLs ' hlsearch ' highlights all the matching words
7. Add no to the option to close the option:: Set Noic
Vim's Learning Notes