首页 > 解决方案 > 如何在每行下分别复制多行并多次粘贴?

问题描述

原文如下。我想复制每一行并分别在他们自己的行下粘贴多次。

USD
XYZ
ABC
YUT
LMO
.
.
. upto so on

想让他们变成这样。无论如何,我怎样才能在 Vim 中实现以下目标?

USD
USD
USD
USD
USD
USD
XYZ
XYZ
XYZ
XYZ
XYZ
ABC
ABC
ABC
ABC
ABC
YUT
YUT
YUT
YUT
YUT
LMO
LMO
LMO
LMO
LMO
.
.
. upto so on

标签: vimputty

解决方案


一种选择是查找/替换整个文件

%s/.*/&\r&/gc

分解

%s    start a substitute on the entire file
.*    capture the entire line to be replaced
&\r&  replace with the entire captured group. Add \r& as amount of required duplicates

推荐阅读