1 repeating last command
In normal mode .
(decimal point) means the last command operation is repeated
Normal mode input x
, delete the first character, the input .
(decimal point) will be deleted again a character, in addition to also can be repeated dd
delete operation
2. Execute commands of the same number of times
Enter Normal mode input N<command>
, n indicates the number of repetitions, and the following is the practice:
Do the following exercises:
- Input
10x
, delete 10 consecutive characters
- Input
3dd
, 3 lines of text will be deleted
In normal mode, you can also dw
daw
delete a word with or (delete a word), so you can easily associate (n with the dnw
corresponding number ) to delete n words
Ii. Quick jump of cursors
In normal mode, the following command allows the cursor to be quickly reversed to the specified position, we discuss the rapid implementation of the inline jump and in-line jump
1. Jump between rows
Command |
Description |
nG (n shift+g) |
Cursor moves to nth row (if no line number is displayed by default, enter command mode first :set nu to display line numbers) |
gg |
Cursor moves to the first row |
G (SHIFT+G) |
To the last line |
Open the practice document using Vim, and then do the following exercises:
- Quickly jump to line 9th and delete the row
- Go back to the first line, delete 8 rows down
- Jump to the end of the document and delete the row
tip: After you have completed the jump, you can use the Ctrl+o
quick to go back to the previous (before the jump) cursor position , this technique is very practical, such as when you write code, suddenly think of a bug, need to change, this time you jump over to change, just need to press Ctrl+o
You can go back to where you were before. Vim will be waiting for you to explore with a lot of similar tips.
2. In-line jump
In normal mode, use the following command to jump within a line in a word
Command |
Description |
w |
To the beginning of the next word |
e |
To the end of the next word |
b |
To the beginning of the first word |
ge |
To the end of the previous word |
0 Or^ |
to the wardrobe. |
$ |
To end of line |
f<字母> |
Search backwards < letters > and jump to the first matching position (very useful) |
F<字母> |
Search forward < letters > and jump to the first matching position |
t<字母> |
Search backwards < letters > and jump to a letter before the first matching position (not used) |
T<字母> |
Search forward < letter > and jump to a letter after the first matching position (not used) |
Do the following exercises in turn:
- In normal mode, jump to a line, use
w
jump to the beginning of a word, and then use dw
the word delete
- In normal mode, use
e
jump to the end of a word and use ~
the letter that contains the cursor to capitalize or lower case
Third, copy paste and cut 1. Copy and paste text
Open the file into normal mode practice the above command, you can now feel free yy
to
$ vim protocols
2. Cut and paste
In fact, the dd
deletion of the command is cut, each time you dd
delete the contents of the document can be used p
to paste, also this allows us to achieve a very refreshing function--exchange up and down line: ddp
, it is so simple, that is, the implementation of the fast Exchange cursor line with the line below it
Vim Document editing