我想在Vim中每一行的末尾添加*。
我尝试了该代码,但没有成功
:%s/\n/*\n/g
我想在Vim中每一行的末尾添加*。
我尝试了该代码,但没有成功
:%s/\n/*\n/g
当前回答
另外:
:g/$/norm A*
另外:
gg<Ctrl-v>G$A*<Esc>
其他回答
甚至比:search命令还短:
:%norm A*
它的意思是:
% = for every line
norm = type the following commands
A* = append '*' to the end of current line
你不需要在最后加上g。所以它变成:
:%s/$/*
或者如果你只想在后面加*,就写14-18行:
:14,18s/$/*
or
:14,18norm A*
:%s/$/\*/g
应该工作,所以应该:%s/$/*/g。
...在每一行的开头加上*,
%s/^/*/g
%s/\s*$/\*/g
这将达到目的,并确保前面的空格被忽略。