VIM: Search only between specific line numbers?

前端 未结 7 959
余生分开走
余生分开走 2020-12-13 09:06

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

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 09:12

    If there marks say a and b, then the search can be restricted to the region between a and b using

    /\%>'a\%<'bSearchText
    

    This can be simplified with a cmap

    cmap vmsab /\%>'a\%<'b
    cmap vmscd /\%>'c\%<'d
    

提交回复
热议问题