Friday, November 11, 2011

Re: python scripting: get current visual selection

On 11/11/2011 12:16 PM, Gelonida N wrote:
> Hi,
>
> I am rather new to the python scripting module of vim.
>
>
> I wanted to write a small test script, which
> is analyzing all text, that I yanked into named buffers. (not sure if
> 'named-buffer' is the correct vi term)
>
>
> Small example
>
> buf_names = 'abcd'
> for buf_name in buf_names:
> yank_buffer = vim.?????('a') # don't know this command
> yank_buf_len = len(yank_buf) # not sure if len() would be right
> print('yank buffer %s contains %d characters' %
> (buf_name, yank_buf_len))
>
>
> I found
> vim.buffers , but this addresses the edit-buffers and not the 'yank-buffers'
>
> Thanks a lot in advance.
>

I think this should work:

text = vim.eval("@a")
print len(text)

They are called registers, not yank buffers, and to get their value in
script, see :h @r

-ak

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

No comments: