Skip to content

Cannot search for regexp spanning multiples lines via counsel-projectile-rg #166

Open
@nordlow

Description

@nordlow

I want to search for a regexp where the whitespace also includes newlines, in my case, to find C-style if-expressions that have an opening brace after the close parenthesis like

if (..) 
{
    ...

The command swiper-isearch understands \n in its minibuffer input and can match such multi-line patterns via for instance if ( ) \n { but counsel-projectile-rg can't with being fed the flag -U. It would be great if it did.

I guess this is related:

https://til.hashrocket.com/posts/9zneks2cbv-multiline-matches-with-ripgrep-rg

Update:

This call rg -U 'if \(.*\) *\n *\{' matches my needs

and in Elisp

(defun counsel-projectile-rg-multiline ()
  "Search the current project with rg pattern spanning multiple lines."
  (interactive)
  (counsel-projectile-rg "--multiline"))

with minibuffer input static if ( ) \n \{ works. Is it standard to have to backquote curly braces in Ivy/Projectile-style searches?

It's not needed with Swiper so I guess we shouldn't need to do that here either for interface consistency.

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