Vim The Vim Editor for Beginners #32

Vim Script with Ranges

function! Range_Search(mypat, start_line, end_line)
    let full_pat = '\%>' . a:start_line . "l" . '\%<' . a:end_line . "l" . a:mypat
    exe '/' . full_pat
    let @/ = full_pat
    norm n
endfunction

command -range -nargs=1 Rs call Range_Search(<f-args>,<line1>,<line2>)
Copyright © 2005 Shlomi Fish