如何将变量的值写入vim脚本中的当前编辑文件

我在vim的脚本中获取变量的值,以及如何将其写入我正在编辑的文件中.

例如

"=== get date
let TodayDate=system("date")
最佳答案
您可以使用:将变量(或表达式)的内容放入当前缓冲区

:put =TodayDate

帮助:h:put

                                                        :pu :put
:[line]pu[t] [x]        Put the text [from register x] after [line] (default
                        current line).  This always works linewise, thus
                        this command can be used to put a yanked block as new
                        lines.
                        The cursor is left on the first non-blank in the last
                        new line.
                        The register can also be '=' followed by an optional
                        expression.  The expression continues until the end of
                        the command.  You need to escape the '|' and '"'
                        characters to prevent them from terminating the
                        command.  Example: 
                                :put ='path' . \",/test\"
                        If there is no expression after '=', Vim uses the
                        previous expression.  You can see it with ":dis =".

对于映射和编辑< C-R> =可能优于:put,因为它允许您使用表达式寄存器并在光标位置输出内容. (看看:h< C-R)

转载注明原文:如何将变量的值写入vim脚本中的当前编辑文件 - 代码日志