Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的文件看起来像这样
a b c d
我希望文件的输出为:
.a(a) .b(b) .c(c) .d(d)
vim 中是否有一个衬线可以这样做?
您可以使用替换:
:%s/.\+/.&(&)/
.\+捕获非空行。&是替换部分内的整个匹配
.\+
&
您可以使用全局:g在所有行上执行.命令norm(^[是插入的转义键<c-v><esc>):
:g
.
norm
^[
<c-v><esc>
:g/./norm diwi.^[pa()^[P
但是您也可以记录您的修改,并根据您的喜好或在一定范围内q重复该修改。@见:h recording。
q
@
:h recording
qq“做你的事情”q选择你的行并运行norm @q,例如:
qq
norm @q
:'<,'>norm @q
或与 g:
:g/./norm @q