Hari Krishna Dara wrote:
> The '> and '< markers identify the start and end position of a selection
> block and it seems to be not updated correctly in one particular case.
> Say you start selection (visual mode or select mode) on one line, and
> use ^E or ^Y to scroll the buffer such that the current line goes past
> the window bounds and cursor is forced to move to the next or previous
> line respectively. This results in the selection getting expanded, but
> the markers still return the old values. Here is a utility map that
> you can press on the block to see the latest values for these markers:
>
> xnoremap <expr> <F12> T()
> snoremap <expr> <F12> T()
> function! T()
> echo 'mode: '.mode().' start: '.line("'<").' end: '.line("'>")
> return ''
> return ''
>
> Once the selection gets expanded, press <F12> on it see that the values
> haven't changed (viz., they both will have the same line numbers, for
> the original line where the selection started.)
The problem is actually the other way around: While Visual mode is
active the '< and '> marks should keep the old values, from a previous
selection. I discovered the marks get set because of the "autoselect"
value in 'clipboard' and the "a" flag in 'guioptions. The patch below
will fix that.
> Anyone can think of an alternate way to identify the correct line
> numbers? The "o" command seems to work fine, but I can't use it as I
> need to do the checks from a CursorMoved handler.
I don't think you can get the position of the other end of the Visual
area directly. Perhaps by stopping Visual mode, using the '< and '>
marks and then using "gv" to select the same area? It would be a lot
simpler if we have a mark for this.
*** ../../vim-7.0.120/src/normal.c Tue Aug 29 17:28:56 2006
--- normal.c Sat Oct 7 14:11:26 2006
***************
*** 1477,1490 ****
}
else if (VIsual_active)
{
! /* Save the current VIsual area for '< and '> marks, and "gv" */
! curbuf->b_visual.vi_start = VIsual;
! curbuf->b_visual.vi_end = curwin->w_cursor;
! curbuf->b_visual.vi_mode = VIsual_mode;
! curbuf->b_visual.vi_curswant = curwin->w_curswant;
# ifdef FEAT_EVAL
! curbuf->b_visual_mode_eval = VIsual_mode;
# endif
/* In Select mode, a linewise selection is operated upon like a
* characterwise selection. */
--- 1477,1493 ----
}
else if (VIsual_active)
{
! if (!gui_yank)
! {
! /* Save the current VIsual area for '< and '> marks, and "gv" */
! curbuf->b_visual.vi_start = VIsual;
! curbuf->b_visual.vi_end = curwin->w_cursor;
! curbuf->b_visual.vi_mode = VIsual_mode;
! curbuf->b_visual.vi_curswant = curwin->w_curswant;
# ifdef FEAT_EVAL
! curbuf->b_visual_mode_eval = VIsual_mode;
# endif
+ }
/* In Select mode, a linewise selection is operated upon like a
* characterwise selection. */
--
hundred-and-one symptoms of being an internet addict:
20. When looking at a pageful of someone else's links, you notice all of them
are already highlighted in purple.
/// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///