作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 vim 的脚本中获取变量的值,以及如何将其写入我现在正在编辑的文件中。
例如
"=== get date
let TodayDate=system("date")
最佳答案
您可以使用:put
将变量(或表达式)的内容放入当前缓冲区
: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 - 如何在vim脚本中将变量的值写入当前编辑文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18200435/
我是一名优秀的程序员,十分优秀!