> 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.
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.)
> 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 must have been added more recently than the 7.2 that Debian
Stable gives me by default. But it sounds like an interesting feature.
> On 10/30/12 12:32, Ben Fritz wrote:
> > 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 must have been added more recently than the 7.2 that Debian
> Stable gives me by default. But it sounds like an interesting feature.
> -tim
> -- > 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
Indeed it is a nice feature. But it doesn't remember the are when
escaping the visual mode (with <esc> or <c-c>). I've asked about it on
vim_dev, and I got an answer that this rather will not be changed in vim
(since it may break some plugins) but there is a workaround: