I'm composing a Vim script and I want to get the currently selected
text in a vmap. I successfully obtained the selected text with @*
under Linux, but it doesn't work for Windows. How can I get such
information?
Thanks
Edward L. Fox
Edward L. Fox wrote:
>
> I'm composing a Vim script and I want to get the currently selected
> text in a vmap. I successfully obtained the selected text with @*
> under Linux, but it doesn't work for Windows. How can I get such
> information?
you are probably missing the "a" flag in guioptions:
set guioptions+=a
Regards,
Jürgen
--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)
Thanks a lot, Jürgen.
But I in fact want a way that I could access the selected text without
effecting the system clipboard. As Windows can't tell the difference
between clipboard and primary selection, every option to the
"selection" will also be applied to the clipboard if I set the
guioption "a", so I think I have to avoid this method.
>
> Regards,
> Jürgen
>
> --
> Sometimes I think the surest sign that intelligent life exists elsewhere
> in the universe is that none of it has tried to contact us. (Calvin)
>
> >
>
Cheers,
Edward L. Fox
Edward L. Fox wrote:
> On 8/8/07, Jürgen Krämer <jott...@googlemail.com> wrote:
>>
>> Edward L. Fox wrote:
>>> I'm composing a Vim script and I want to get the currently selected
>>> text in a vmap. I successfully obtained the selected text with @*
>>> under Linux, but it doesn't work for Windows. How can I get such
>>> information?
>> you are probably missing the "a" flag in guioptions:
>>
>> set guioptions+=a
>
> Thanks a lot, Jürgen.
>
> But I in fact want a way that I could access the selected text without
> effecting the system clipboard. As Windows can't tell the difference
> between clipboard and primary selection, every option to the
> "selection" will also be applied to the clipboard if I set the
> guioption "a", so I think I have to avoid this method.
you can also yank the current visual selection to a named register with
"ay
If you want to take care not to destroy the content of a register then
you can save and restore it
vnoremap <F12> :<c-u>
\let old_reg=getreg('a')<bar>
\let old_regmode=getregtype('a')<cr>
\gv
\"ay
\...
\:call setreg('a', old_reg, old_regmode)<cr>
The actual code of your map is represented by the three dots.
Thanks, it works fine!
You can also use the unnamed register (with just y) then either save it in a
variable -- :let selection = @@ -- or use it before you've had time to
overwrite it.
Best regards,
Tony.
--
It has been said [by Anatole France], "it is not by amusing oneself
that one learns," and, in reply: "it is *only* by amusing oneself that
one can learn."
-- Edward Kasner and James R. Newman