Search code examples
vim

Search only between specific line numbers?


I know that with Vim's substitution command you can specific a range of lines:

:12,24s/search/replace

I want to be able to specify a range with normal searches as well. Something like

:12,24/search

Since that doesn't seem to work (at least on my Vim configuration), does anybody know how to achieve this?


Solution

  • :help search-range
    

    and then

    :help /\%>l
    

    so essentially:

    /\%>12l\%<24lsearch