Wednesday, September 6, 2017

Re: quick question: what is the function or command to insert text, from a variable, in current cursor pos?

On 2017-09-06, Jose Caballero wrote:

> I trying to modify an plugin that I already have in such a way that,
> after adding the lines it already does and moving the cursor to a
> given position, now it also adds the name of the file in that
> position.
>
> I know how to get the name of the file in a variable.
>
> But what is the function I need to call in order to insert (not
> append), that variable content where the cursor is?
> I am trying put, but it does seem to do exactly what I am looking for.

If you already have the name of the file in a variable, call it var,
then the following will insert the value of var at the current
cursor location.

exe "normal i\<C-R>=var\<CR>"

See

:help :exe
:help :normal
:help i_CTRL-R_=

HTH,
Gary

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: