Skip to content

A flag for words that might be on different lines #3533

Description

@lumynou5

Describe your feature request

This proposes two new flags: --wrapped-words and --wrapped-chars. They can't be used together. Both must be used with -F (--fixed-strings).

They are for CLI convenience in a very common scenario: you want to search for a phrase, and the target files have line wrapping. Usually, you need to use \s+ between words in order to match newlines and potential indents. With the new flags, you can do

rg -F --wrapped-words 'the brown dog jumped over the lazy fox'

which is the same as

rg -U 'the\s+brown\s+dog\s+jumped\s+over\s+the\s+lazy\s+fox'

but makes life easier.

--wrapped-chars behaves similarly except it inserts \s+ between each character instead of replacing space characters. It's mainly for scripts not using spaces, e.g. CJK ideographic.

rg -F --wrapped-chars '雨一直下'

means

rg -U '雨\s+一\s+直\s+下'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions