VIM: Search only between specific line numbers?

前端 未结 7 950
余生分开走
余生分开走 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:32

    Keep using the substitution command, but append the gc flags to your original example.

    :12,24s/search//gc

    From :help search-range

    [To search within a range] use the ":substitute" command with the 'c' flag.

    Example: :.,300s/Pattern//gc

    This command will search from the cursor position until line 300 for "Pattern". At the match, you can type 'q' to stop, or 'n' to find the next match.

提交回复
热议问题