使用 for 循环在 Vim 中写入行
Write lines in Vim using a for loop
如何Vim根据非常简单的算术模式将行写入文件?
示例:
foo1
foo2
foo3
...
foo99
foo100
我使用 Ex 命令想出了以下解决方案
:for i in range(1,100)
: execute "normal ofoo" . i
:endfor
但我相信一定有更直接的东西。
类似于:
:let l = map(range(1,100), '"foo".v:val')
:put=l
" Unfortunately put won't accept the expression, append() would though
call append(line('.'), map(range(1,100), '"foo".v:val'))
我会用宏来做。
首先输入一行:
foo1
然后
qqYp<c-a>q
终于重播宏:
98@q
如何Vim根据非常简单的算术模式将行写入文件?
示例:
foo1
foo2
foo3
...
foo99
foo100
我使用 Ex 命令想出了以下解决方案
:for i in range(1,100)
: execute "normal ofoo" . i
:endfor
但我相信一定有更直接的东西。
类似于:
:let l = map(range(1,100), '"foo".v:val')
:put=l
" Unfortunately put won't accept the expression, append() would though
call append(line('.'), map(range(1,100), '"foo".v:val'))
我会用宏来做。
首先输入一行:
foo1
然后
qqYp<c-a>q
终于重播宏:
98@q