How to insert text from inside a vimscript loop?

天涯浪子 提交于 2019-12-12 14:31:44

问题


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?


回答1:


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.)



来源:https://stackoverflow.com/questions/28511027/how-to-insert-text-from-inside-a-vimscript-loop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!