Requirements Description
1. If you change all Chinese names in English to "fan Jianqiang" to "Qiangjian fan"
2. Turn all the "Change World,change mind! "Replace" change mind, change world! ”
3. Swap the age column and ID column for the following sample data
Name Age ID slary
A 20 1 10
b 19 2 10
C 21 3 10
D 21 5 10
E 22 4 10
F 23 6 10
G 23 7 10
H 17 8 10
J 24 10 10
K 26 9 10
Command implementation
The most direct approach to 1, 2 needs is to replace the whole text; for Demand 3, you can use block selection, then cut, paste! But not what Ben Boven to elaborate. Here's another way to implement this:
Requirement 1 command
:%s/\ (fan\) \ (jian\) \ (qiang\)/\3\2 \1/
Requirement 2 Command
:%s/\ (world\), change \ (mind\)/\2, change \1/
Requirement 3 Command
:%s/\ ([1-9][0-9]\) \ ([1-9].\)/\2 \1/
This is how \ (\) is used
The pattern contained therein will be stored, numbered from left to right, with a maximum of 9 stored in one row. Access them by numbered access! For example, the above requirements 2,world saved to the number 1,mind to the number 2; so \2, change \1 the world and mind, changed the world, and replaced! Demand 1 and Demand 3 the same!
Description: Because \ and (combined into the escape of the Web page Italic font.) Instead of showing, here each \ and (between the spaces, note that the space is not part of the command
The order of words exchanged in Vim line and the column exchange of text data