Tuesday, October 30, 2012

Re: re-selecting block in different buffer

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.

So you could do something like

:nnoremap <leader>v `[v`]
:nnoremap <leader>V `[V`]
:nnoremap <leader><c-v> `[<c-v>`]

to reselect the pasted contents in the given mode.

-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

No comments: