how to write value of variable into current edit file in vim script
vim
Solution
You can use `:put` to put the contents of the variable (or expression) into the current buffer
:put =TodayDate
The help for `: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 =".
For mappings and editing `<C-R>=` is probably better than `:put` since it allows you to use the expression register and output the contents at the cursor location. (Take a look at `:h <C-R>`)
Problem
I get a variable's value in vim's script, and how to write it into the file I'm editing now. e.g. ``` "=== get date let TodayDate=system("date") ```