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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Jose Caballero
Hi,

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.

Any hint is more than welcome.

Thanks
Jose

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Gary Johnson-4
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Jose Caballero
2017-09-06 9:11 GMT-05:00 Gary Johnson <[hidden email]>:

> 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
>

Thanks a lot!
It works perfectly.

Jose

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.