如何从vimscript循环中插入文本? [英] How to insert text from inside a vimscript loop?

查看:107
本文介绍了如何从vimscript循环中插入文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

:help while文档中可以看到:

NOTE: The ":append" and ":insert" commands don't work
properly inside a ":while" and ":for" loop.

我可以确认他们没有.但是我该怎么用然后在循环中插入文本?

And I can confirm they don't. But what should I use then to insert text from inside a loop?

推荐答案

:insert:append命令主要用于交互使用.在Vimscript中,您可以改为使用较低级的setline()append()函数,这些函数在循环中效果很好. (它们也更易于使用,因为您可以直接向它们传递行列表.)

The :insert and :append commands are mostly meant for interactive use. In a Vimscript, you can instead use the lower-level setline() and append() functions, which do work well in a loop. (They are also easier to use, because you can directly pass a List of lines to them.)

这篇关于如何从vimscript循环中插入文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆