Friday, November 11, 2011

Re: python scripting: get current visual selection

On 11/11/11 18:56, AK wrote:
> On 11/11/2011 12:49 PM, Gelonida N wrote:
>> On 11/11/2011 06:39 PM, AK wrote:
>>> 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)
>>>>
>>
>>>
>>> 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
>>>
>> Thanks a lot AK and Tony,
>>
>> This helps me a lot. (also getting the nominclature right)
>>
>> Is there a register for the contents of the current visual selection
>> (before I pressed 'y') or would I have to fetch this contents
>> differently (force for example a yank to a register ufront)
>>
>>
>>
>
> It might be in + or * register on unix? But a more reliable way is to
> yank it into a register, you can then restore selection using gv
> command: :h gv
>
> -ak
>

+ is the clipboard (as in Edit => Paste); * is the X11 selection (as in
<MiddleMouse>). Vim's visual selection isn't put in a register unless
you have :set clipboard=autoselect (in console mode) or :set
guioptions+=a (in gvim) (see :h 'clipboard' and :h guioptions-a ).


Best regards,
Tony.
--
Don't change the reason, just change the excuses!
-- Joe Cointment

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