Подтвердить что ты не робот

Как записать значение переменной в текущий файл редактирования в vim script

Я получаю переменное значение в vim script, и как записать его в файл, который сейчас редактирую.

например.

"=== get date
let TodayDate=system("date")
4b9b3361

Ответ 1

Вы можете использовать :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>)