Nikolai Weibull wrote:
> I have the following function and binding:
>
> noremap <silent> g: <Esc>:set operatorfunc=<SID>get_command_mode_range<CR>g@
>
> function! s:get_command_mode_range(type)
> let b = line("'[")
> let e = line("']")
>
> if b < e
> let range = '.,+' . (e - b)
> elseif b == e
> let range = '.'
> else
> let range = '.,+' . (b - e)
> endif
>
> call feedkeys(':' . range, 'n')
> endfunction
>
> If I start on the first line of the function, that is, "function!..."
> and press g: followed by / and then searching for "endf" and pressing
> enter, my command line will be
>
> :.,+12
>
> However, endfunction is actually on the thirteenth line after
> function!, so the range should really be .,+13. If i instead search
> for "ndf" I get the correct result.
>
> So it seems that there's something strange going on in what line is
> being set for the ] mark when performing a search under these
> conditions, coupled with patterns that match at the very beginning of
> a line.
There are a few special ways operators handle movements. Note that the
"/" is "exclusive", which means the end position of the cursor is not
included in the operated text. When this position is at the start of
the line, that line is not included. It's like the cursor ends up just
after the end of the previous line. Try it with "d/pat<CR>". This is
to make it Vi compatible. And mostly it does what you expect.
--
Place mark here ->[ ]<- if you want a dirty monitor.
/// 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 ///
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---