Sunday, June 14, 2015

Re: pass vim variable to python script

2015-06-14 20:31 GMT+03:00 Rick Dooling <rpdooling@gmail.com>:
> On Sunday, June 14, 2015 at 11:36:01 AM UTC-5, ZyX wrote:
>> 2015-06-14 18:26 GMT+03:00 Rick Dooling:
>> > So let's say I want the current line number in the Vim Buffer
>> >
>> > let x=line(".")
>> >
>> > And then I want to do something with it inside my Python script.
>> > How do I refer to it? Or if there is a way to get the current line number using the python vim module? I see vim.current.line but this is a string of the line itself?
>> >
>> >
>> > function! Script()
>> >
>> > let x=line(".")
>> >
>> > python << EOF
>> >
>> > import vim
>> >
>> > (how to refer to x?)
>>
>> :h if_pyth.txt, it contains answers to both questions.
>>
>> First, there is vim.bindeval/vim.eval.
>> Second, there is vim.current.window.cursor.
>>
>> >
>> >
>> > EOF
>> >
>> > Thanks
>> >
>> > Rick
>> >
>> > --
>> > --
>> > 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.
>> >
>> > For more options, visit https://groups.google.com/d/optout.
>
> Ah, thank you, Zyx! I was just looking under buffers, not windows. The window thing works!

Cursor has nothing to do with buffers. You can have one buffer
displayed in two windows with different cursor position, including
different cursor line.

>
> As for vim.eval. I am not a computer scientist, just an amateur scripter. I read it three times and could not make sense of it. Maybe someday!
>
> Thanks again,
>
> Rick
>
> --
> --
> 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.

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