Searching line-wrapped paragraphs #2485
-
Suppose I read some documentation and find a typo or want to improve something at the exact point I’m looking at. I can try
to locate the source. However, documentation files (be it md, rst, …) typically consist of paragraphs with line breaks. So in fact I need
I find myself in this situation pretty often. Would there be a point in adding a “paragraph mode” to ripgrep? In such a mode, single line breaks would essentially be treated as spaces for the purpose of matching. Or did I miss the magic switch for this in the documentation? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I also run into this problem occasionally, but it's not just because of paragraphs. It also happens with, for example, string literals. In Rust: let foo =
"This string is \
split across \
multiple lines."; And in Go: foo := "this string is" +
"split across" +
"multiple lines" And in this case, the suggested paragraph mode doesn't really work. Indeed, there really isn't a single approach for how string literals might be wrapped. But I run into this sort of case myself too. To be honest, what I usually do is just change my query to use fewer words under the assumption that there is a break between them somewhere. And that usually solves my problem. Your solution for paragraph breaks specifically is good. Otherwise, I don't think it's worth adding a special purpose feature for this to ripgrep. It would be difficult to discover and would only work in certain cases. |
Beta Was this translation helpful? Give feedback.
I also run into this problem occasionally, but it's not just because of paragraphs. It also happens with, for example, string literals. In Rust:
And in Go:
And in this case, the suggested paragraph mode doesn't really work. Indeed, there really isn't a single approach for how string literals might be wrapped. But I run into this sort of case myself too.
To be honest, what I usually do is just change my query to use fewer words under the assumption that there is a break between them somewhere. And that usually solves my problem. Your solution for pa…