Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support multiline search #20

Open
windwp opened this issue Jun 27, 2021 · 12 comments
Open

support multiline search #20

windwp opened this issue Jun 27, 2021 · 12 comments
Labels
enhancement New feature or request help wanted Extra attention is needed pinned

Comments

@windwp
Copy link
Collaborator

windwp commented Jun 27, 2021

support multiline search

                ['multiline'] = {
                    desc = 'search multiline',
                    icon = '[M]',
                    value = '--multiline',
                },

problem

  • if we add this to rg search option we can search across multi line with \n but it have wrong total result because we read everyline and map it to a result

  • the highlight is not correct too because we use vim to highlight vim doesn't support \n. It only read 1 line to highlight

  • sed is not support replace with range on multiple line. I use sed because it use a same syntax of vim and vim group name replace. but it will broken on multiple

https://github.com/microsoft/vscode/blob/b385fa7ceb2b537e0ba2b58edaa162f4e299a947/src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts

current solution is search 1 line and use quickfix to run macro cdo 😄

@stale

This comment was marked as off-topic.

@stale stale bot added the wontfix This will not be worked on label Sep 25, 2021
@windwp windwp added enhancement New feature or request help wanted Extra attention is needed and removed wontfix This will not be worked on labels Sep 25, 2021
@stale

This comment was marked as off-topic.

@stale stale bot added the wontfix This will not be worked on label Nov 24, 2021
@windwp windwp added pinned and removed wontfix This will not be worked on labels Nov 25, 2021
@windwp
Copy link
Collaborator Author

windwp commented Mar 5, 2022

it have some problem to use vim matchstr to highlight sample
you can search pattern [\w\.]* but vimregex don't allow use \w inside [] it need to change to `[a-zA-Z.]* and sed don't support than pattern to replace.

@danielo515
Copy link

Is this a wont-fix?
I will be happy to have all the search results in one page and be able to edit them manually.

@mercxry
Copy link

mercxry commented Feb 15, 2023

Any updates on this? This is one of the few reasons where I find myself opening VSCode 😅

@vizcay
Copy link

vizcay commented Jul 18, 2023

Have to admit, in the ocassions needed (like now for me 😆), this will be really useful.

@EpsilonKu
Copy link
Member

with #17 it motivates me to use another replace tool or write own. Will look to it

@akoskm
Copy link

akoskm commented Mar 6, 2024

I don't want to fire up VSCode for changes like these 😃 Any solutions? Doesn't have to be in spectre, sed is fine too.

Sometimes I want to remove file owner comments bulk, something like this (note the new line after the comment):

// @team TeamA

With sed I could remove the first line:

find . -type f -name '*.*' -exec sed -i '' '/^\/\/ @team TeamA$/d' {} +

But I can't remove the extra newline after. I tried to get answers from ChatGPT, but it always ended up removing more lines than I initially wanted.

@yriveiro
Copy link

Hi,

Found myself in the same situation, not being able to also replace the '\n' at the end of the string to not replace with an empty line force me to use another tool than Spectre 😭

@akoskm
Copy link

akoskm commented Mar 22, 2024

another tool

care to share?

@pithecantrope
Copy link

In python, you can add inline flag with (?m) - multiline, (?i) - ignorecase and so on. I would LOVE to see this! The fact that there is no Multiline search is terrifying :(

@yriveiro
Copy link

another tool

care to share?

In my case I was removing items from a YAML list, I ended up crafting a small Python script and the replacement at scale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed pinned
Projects
None yet
Development

No branches or pull requests

8 participants