Learn vi and vim editors (3): simple text editing (2)
In the previous article, I will continue to explain some simple text editing commands in the vi editor. This article mainly involves commands such as text deletion, copying, and moving.
Delete text:
As mentioned in the previous article, the DELETE command ("d") also has the form of "(command) (TextObject, command represents commands such as Delete ("d") and replace ("c"), while TextObject refers to the cursor movement command, which represents the range of text objects affected by command. As long as you remember this, you do not need to remember the combination of the next DELETE command:
Dw: Delete the cursor to the end of the word (w is to move a word backward in the cursor movement command). Note that this command will delete the blank space after the word;
De: it is the same as the dw command, but will not delete the blank space after the word;
DE: Delete to the end of a word including punctuation marks;
D $: Delete the cursor to the end of the row, which is the same as the D command;
D0: Delete the cursor from the beginning of the row;
Dd: The entire row is directly deleted no matter where the cursor is in the row;
There are more than one combination of the d command and the cursor movement command, so we will not give an example here. As long as we understand the form of the combination, we do not need to remember it. Here are two additional cursor movement commands: "e" and "E", both of which move the cursor to the end of the word, but the "e" command moves to the end of the word, the "E" command is moved to the punctuation mark of the word.
If you need to delete characters, there are simpler commands, of course, these commands can also add numerical parameters:
X: Delete the character of the cursor;
X: delete a character before the cursor;
An error occurred when deleting the file: if the text is deleted by mistake, how can this problem be solved? You can use the u command to undo the previous command. However, since u only revokes the most recent command, u command recovery can only be used when other editing commands are not yet issued. I personally think there is a problem in the book, because when I delete 10 rows in a row, and then press 10 u consecutively, the original State can still be restored, as shown in, 10 rows to be deleted:
When you press ten "dd" commands in a row and then press ten "u" commands in a row to restore the original state, so I think there is a problem in the book. record it for now.
Move text:
In the vi editor, you can move a text block by deleting it before placing it. Each time you need to move a text block, you can delete it first, in this way, the content of the text block will be stored in a special buffer, move the cursor to the correct position, and place the deleted text in the new position using the placement command (p, to move the text. <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> Release + release/release + XH + NbQtcTOxLG + release 41cm + s/release/bBy9K7uPbTsM/release/X96Ooyb6z/aOszc/release + vs274c/large + large/ydLUzai5/large + o7o8L3A + CjxwPri01sbOxLG + large/zB7tKyvt/large/small/large + large/small + + large/small/zB7rXE1 + release/release + release/release + dLUw7/release + s/278s3P0rfD/release + CjxwPtbYuLTD/release/MHuoaM8L3A + CjxwPrO3z/rD/release + cjxwww + release/release/6yc/release/zB7r/J0tSzt8/6y/release + release/release + yc/release + tcTD/MHuo7o8L3A + release + o7s8L3A + release + release/nU2s671sO1xM/release + dTazrvWw7XEyc/release + release/3By2/T60/D/MHuo6y2vL/release + zb/release + release/release + 9bKisrvKx8Ltyc ++ zbP2wLTBy6Os0qq1yL2rvfwxw + vW06O6PC9wPgo8cD48aW1nIHNyYz0 = "http://www.2cto.com/uploadfile/Collfiles/20141024/2014102409241367.png" alt = "">
Use the J command to merge two rows. if you add a numerical parameter before the J command, you can specify the number of rows to be merged.
Summary of the vi editor commands in this chapter:
D, D, dd, e, E, p, y, Y, yy,., u, U, A, I, o, O, J.