% vi textfile (Before Substitution)

Unusual occurrences happened at the fair.

Patty won fourth place in the 50 yard dash square and fair.

Occurences like this are rare.

The winning ticket is 55222.

The ticket I got is 54333 and Dee got 55544.

Guy fell down while running around the south bend in his last event.

 

1.  :s/\{square\} and \(fair\)/\2 and \1/

% vi textfile (After Substitution)

Unusual occurrences happened at the fair.

--->Patty won fourth place in the 50 yard dash fair and square.

     Occurrences like this are rare.

    The winning ticket is 55222.

    The ticket I got is 54333 and Dee got 55544.

   Guy fell down while running around the south bend in his last event.

说明

    编辑器搜索正则表达式 square and fair.将square 标记为#1,并将fair标记#2.在需要替换的一侧,将#2的内容替换为\2,将#1的内容换为\1.请参考图2.2所示。