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

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

问题描述

:help while 文档中可以看出:

It appears from the :help while documentation that :

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天全站免登陆