Tuesday, November 30, 2010

Re: How to find start/end of char-wise visual selection?

On Wed, December 1, 2010 4:26 am, AK wrote:
>
> Hi, this is for Vim7.3.. Looking up docs for line(), it says that
> arg='.' will give you cursor position, and 'v' will give you beginning
> of visual selection when in visual mode, and '.' will give you the end
> of it. For column, col() should be used, but there's no 'v' arg for it.

Yeah, I remember, I wondered about it too. I even thought about creating
a patch, but didn't so far, because you can easily get the column using
the getpos() function together with the marks '< for start and '> for end
of visual selection. For my plugin NrrwRgn, I use getpos("'>") for the line
and virtcol("'>") for the virtual column of the end of the visual selection
(and the same for the start of the visual selection).

> So, how can I do this? Let's say I have a char-wise selection from
> column 10 to 20, how can I get numbers 10 and 20? -ak

echo "start at line " getpos("'<")[1] " column: " virtcol("'<")
echo "end at line " getpos("'>")[1] " column: " virtcol("'>")

regards,
Christian

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