Tuesday, October 30, 2012

Re: re-selecting block in different buffer

On Tuesday, October 30, 2012 11:18:04 AM UTC-5, Tim Chase wrote:
> On 10/30/12 11:11, Chris Lott wrote:
> > The gv command is very useful. I'd like to be able to reselect a block
> > after I have selected, cut, and pasted it into a different buffer.
> >
> > Is this possible?
>
> It's a little tricky. Vim does track the `[ and `] marks for you
> which can be used to find the beginning/end of the block. However,
> since you're now in another window/buffer, I don't know of any way
> to get Vim to know whether the paste was from a
> linewise/characterwise/blockwise selection. There is a visualmode()
> function, but it only gives you the most recent visual mode for the
> *current* buffer.
>

Vim remembers the previous mode though, and while it might not be accessible,
you can select the same area and mode in a different place by using 1v. The help
on this is a little hard to find, it does not have its own topic, it is right
above :help v_<Esc>.

This works for me, to select the pasted text in the correct mode:

`[1v

(Note, it doesn't QUITE work with the 'selection' set to "exclusive", it selects
one character too few. This may be a bug.)

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