On Aug 12, 5:05 am, winterTTr <[email protected]> wrote:
> I give an alternate way
>
> function! VModeSearchRange()
>         return '\%>' . ( line("'<") - 1 ) . 'l\%<' . ( line("'>") + 1 ) .  'l'
> endfunction
>
> vnoremap / <ESC>/<C-R>=VModeSearchRange()<CR>
>
> You can v-select the range you want to search and then press "/",
> continue type the word you want to search.
>

There is no need for an extra function to restrict your search to
visual mode, you can just use \%V in your pattern.

This is how I normally restrict a search range.

For example, to restrict a search to the current {...} block:

vaB<Esc>/\%Vpattern<Enter>

I use this often enough I've defined a mapping as well:

vnoremap <M-/> <Esc>/\%V
nnoremap <M-/> /\%V

I diddn't want to remap / by itself, because being able to search to
extend the range of a visual selection is way too useful to lose.

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

Reply via email to