ripgrep 0.10.0, released on September 7, 2018, adds an opt-in way to search across line breaks. Developers can enable it with -U or --multiline; ordinary searches remain line-oriented by default. For teams using the command-line search tool in scripts, the trade-off is how input arrives: a pattern that can cross lines may require the whole input before searching can begin. [S1][S2][S3]
The new mode removes a restriction on what a match can contain. In the normal mode, ripgrep rejects a regular expression that explicitly matches a newline. Multiline mode permits it. That gives developers a way to look for a pattern spanning several lines of a file rather than treat each line as a separate search boundary. The release documentation sets no limit on the number of lines a single match may span. [S2][S3]
Turning on multiline search does not make the dot character match newlines. In ripgrep 0.10.0, dot still excludes a newline unless the pattern enables dot-all behavior, or the user also supplies --multiline-dotall. That second flag has no effect without multiline mode. A search that depends on a dot crossing a line break therefore needs both decisions: allow a match to cross lines, and let the dot consume those line breaks. [S2]
The storage cost depends on the pattern. The version's help text warns that multiline searches may take longer and use more memory. When cross-line matching requires it, each searched file must be available contiguously in memory, either read into heap memory or memory-mapped. Standard input cannot be memory-mapped, so in that case ripgrep consumes it through the end-of-file marker before beginning the search. For an input stream that stays open, the practical implication is that waiting for results can reflect waiting for the stream to end, rather than a failed match. [S2]
There is an exception: when --multiline is set but the expression contains no pattern capable of matching a newline, ripgrep avoids reading each whole file into memory first. The switch alone is not proof that a job will buffer all its input. For script owners, the useful test is whether the pattern actually needs to cross lines and whether the input has a definite end. The maintainer's advice is to leave multiline mode disabled when matches need to span only one line. [S2]
Source documents
- ripgrep 0.10.0 release recordhttps://api.github.com/repos/BurntSushi/ripgrep/releases/tags/0.10.0
- ripgrep 0.10.0 multiline command-line help sourcehttps://raw.githubusercontent.com/BurntSushi/ripgrep/0.10.0/src/app.rs
- ripgrep 0.10.0 tagged changeloghttps://raw.githubusercontent.com/BurntSushi/ripgrep/0.10.0/CHANGELOG.md
