Answers:
:%s/$/\*/g
应该管用。因此,应该:%s/$/*/g为MrWiggles正确地指出。
g标志是不必要的。
甚至比:search命令还短:
:%norm A*
这是什么意思:
% = for every line
norm = type the following commands
A* = append '*' to the end of current line
:,即可预填命令,:'<,'>然后您可以将其变为:'<,'>norm A*
I代替-:%norm I*
我认为使用可视块模式是处理此类问题的更好,更通用的方法。这是一个例子:
This is the First line.
This is the second.
The third.
插入“ Hello world”。(空格+剪贴板)在以下各行的末尾:
结果是:
This is the First line. Hello world.
This is the second. Hello world.
The third. Hello world.
(来自Vim.Wikia.com的示例)
jj一下就G可以移动到最后一行。这在大型文件中很有用,在这种情况下,j一直按到最后一行都是不切实际的。
:%s / \ n / * \ r / g
您的第一个在其他任何地方都是正确的,但是由于某种原因,Vim必须使用不同的换行符处理。
:s///,它\n对应一个空字符。本节:help sub-replace-special是相关的。