You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Find dialog (Ctrl+F) does not allow multi-line finds using the \n character as it currently considers each line individually. See TextModel._doFindMatches
Reacted by eshizhan, eSoares, Arda Kılıçdağı, Eser Ozvataf, tuxtina, Carsten Ganske, Belleve, Viktor Eriksson, Hao Zhang, Sebastian Holmqvist and 52 more
Reacted by Patrick Buergin, Sushruth Sastry and Luca M
Indeed, the find is executed on a line by line basis. To implement multi-line search we need to do the following:
maintain a fast [offset] <-> [line number, column] mapping data-structure in the model. I think PrefixSumComputer can handle this easily, as long as it's updated correctly on edits.
when searching, we need to get the entire text inside the search range as one string
run the regex on the one string
get back offsets
use the above data-structure to convert back to [line number, column] coordinates.
It is a little bit of work to get all of this done.
+1
Unfortunately it's a common omission from text editors, presumably due to simplicity of line-based text representation / search model. But nevertheless it's a very useful feature for day-to-day work.
Please please fix!
Another question is if VS Code's regex search supports inline flags like Sublime ie (single line, . matches new line): (?s)<fieldset>.*<legend>
In this example this is useful for finding a legend tag after or possibly within a fieldset tag, whether or not it's on the next line from fieldset.
Joe Seifi (@joeshub), you should be able to match against newlines now with \s ... I'm also able to match more explicitly with \r?\n (CR is for potentially crlf/windows line endings). It's working for me in the most recent march 2017 release (1.11.2).
Michael J. Ryan (@tracker1) I see thank you. this works but only for open files in VS Code. Please tell me I don't have to open every file in my project before searching w/ regex :)
Reacted by Mike Matuszak, Ramin, Eticom Ltd, t d h smith, Jasper Schulte, Josh Kramer, Andrew Branch, Alexander Shutau, Ravi Mehra, Haroen Viaene and 3 more
Why is this closed? Multiline regex find and replace does not work in 1.13.1. Looks like it finds only in opened buffers, but how useful is that?
Reacted by Jitbit (the company behind "Jitbit Helpdesk" software), Andrei Neculau, M0D27, Joe Chung, Frank, Jonas Goslow, Adrien Delorme, Nicolaj Schweitz, Richard Taylor, Aldo Fregoso and 5 more
The workaround for doing something like a negative lookbehind assertion using mult-lines. You can do something like.
(?<!configService'[\s\S\r]+?)config.
This is searching for the string "config." (no double quotes) that is not proceeded by "configService'" (no double quotes) and any/all characters with multiple lines in between.
As an aside, I stopped logging bugs against Microsoft products because they'll never fix them for you even if they appear high severity years ago.
I haven't bothered for over 5 years. It's a waste of time, even if the issue high severity. You can google my name and Microsoft bug and see my rants at times in the past. Now I'm zen about it and just don't care. ;)
Jeff Fischer (@windhandel)
It's nice with VSCode as I believe this is a separate section of the team that gets to operate differently. Especially since this is open source you get to see a lot more of the ins & outs of how this team is operating. Given it's open source you get the opportunity to fix the code up yourself if you have the time and know how.
Reacted by Waldir Pimenta, Rafael Salguero Iturrios, Aldo Fregoso, Alan McBee, Melvin and Jeff Fischer
Jeff Fischer (@windhandel) It's a double edged sword. You might write bug-free code (do you?) but if nobody else is using it, it's not so great. On the other hand, if you are a mere mortal like the rest of us, and you write code that a lot of people use, you will be prompted to publish it with what you hope are not too many bugs as well as requests for new features. Life becomes a careful balance of fixing just enough bugs, adding just enough new features, to keep your code popular and useful. And, especially in the world of open source where anyone can fix bugs, we hope that everyone helps keep the balance.
Activity
[-]Find does not match across lines[/-][+]Find does not match multi-line regex strings[/+]alexdima commentedon Nov 24, 2015
Indeed, the find is executed on a line by line basis. To implement multi-line search we need to do the following:
It is a little bit of work to get all of this done.
sushruth commentedon Mar 9, 2016
👍 (commenting to get updates on this)
ZombieProtectionAgency commentedon Mar 11, 2016
Sushruth Sastry (@sushruth) FYI there is a "Subscribe" button to the right on github that lets you follow the thread without commenting.
Ardakilic commentedon Apr 15, 2016
I got the newest update today, and I still suffer from this.
I almost always use multi line regex, and this is the only feature that's keeping me away from daily usage.
So +1.
3-1415926 commentedon Apr 22, 2016
+1
Unfortunately it's a common omission from text editors, presumably due to simplicity of line-based text representation / search model. But nevertheless it's a very useful feature for day-to-day work.
Please please fix!
jmrnilsson commentedon May 2, 2016
👍 I would love this feature as well.
LyZane commentedon May 5, 2016
+10086
klauszhang commentedon May 6, 2016
This can be very useful. +++. hope we can have this soon!
0x3333 commentedon May 6, 2016
Come on people. Subscribe. Stop spamming. Will not help comment on this.
21 remaining items
g5codyswartz commentedon Oct 7, 2016
I'm unable to get this to match

Running this on regex101 seems to work fine

Another question is if VS Code's regex search supports inline flags like Sublime ie (single line, . matches new line):
(?s)<fieldset>.*<legend>In this example this is useful for finding a legend tag after or possibly within a fieldset tag, whether or not it's on the next line from fieldset.
Tyriar commentedon Oct 7, 2016
Cody Swartz (@g5codyswartz) nice find, I created #13369
Not sure about inline flags.
johankvint commentedon Feb 24, 2017
Is this fixed? Still can't do multiline regex on VS Code 1.9.1, Mac
joeshub commentedon Apr 1, 2017
what was the resolution to this issue?
tracker1 commentedon Apr 13, 2017
Joe Seifi (@joeshub), you should be able to match against newlines now with
\s... I'm also able to match more explicitly with\r?\n(CR is for potentially crlf/windows line endings). It's working for me in the most recent march 2017 release (1.11.2).joeshub commentedon Apr 14, 2017
Michael J. Ryan (@tracker1) I see thank you. this works but only for open files in VS Code. Please tell me I don't have to open every file in my project before searching w/ regex :)
tdhsmith commentedon Apr 27, 2017
Yeah that behavior (where "find in files" only returns results in open buffers) is misleading at best. Nothing even warns you that it's occurring.
umpirsky commentedon Jul 8, 2017
Why is this closed? Multiline regex find and replace does not work in 1.13.1. Looks like it finds only in opened buffers, but how useful is that?
windhandel commentedon Jul 28, 2017
In case anyone is still struggling with this.
The workaround for doing something like a negative lookbehind assertion using mult-lines. You can do something like.
(?<!configService'[\s\S\r]+?)config.
This is searching for the string "config." (no double quotes) that is not proceeded by "configService'" (no double quotes) and any/all characters with multiple lines in between.
windhandel commentedon Jul 28, 2017
As an aside, I stopped logging bugs against Microsoft products because they'll never fix them for you even if they appear high severity years ago.
I haven't bothered for over 5 years. It's a waste of time, even if the issue high severity. You can google my name and Microsoft bug and see my rants at times in the past. Now I'm zen about it and just don't care. ;)
There's a reason why I'm no longer an FTE.
Here's a nice WCF bug that's active from 2013 - http://www.beta.microsoft.com/VisualStudio/feedbackdetail/view/779111/wcf-rest-service-two-set-cookie-http-headers-invalid-set-cookie-header-syntax
g5codyswartz commentedon Jul 28, 2017
Jeff Fischer (@windhandel)
It's nice with VSCode as I believe this is a separate section of the team that gets to operate differently. Especially since this is open source you get to see a lot more of the ins & outs of how this team is operating. Given it's open source you get the opportunity to fix the code up yourself if you have the time and know how.
CodeCharm commentedon Aug 19, 2017
Jeff Fischer (@windhandel) It's a double edged sword. You might write bug-free code (do you?) but if nobody else is using it, it's not so great. On the other hand, if you are a mere mortal like the rest of us, and you write code that a lot of people use, you will be prompted to publish it with what you hope are not too many bugs as well as requests for new features. Life becomes a careful balance of fixing just enough bugs, adding just enough new features, to keep your code popular and useful. And, especially in the world of open source where anyone can fix bugs, we hope that everyone helps keep the balance.
BTW, did you know that WCF is open source? https://github.com/dotnet/wcf
kuaipaowoniu commentedon Aug 22, 2017
Format my code, appear in the following format:
_self
.model
.personClassify(classify);
But I want to keep my code in the same line, for example:
_self.model.personClassify(classify);
How should I configure?
CodeCharm commentedon Oct 12, 2017
键盘人生 (@kuaipaowoniu) This is not that hard, but you'll want to learn more about regular expressions.
In VS Code, 1.17.0, search for this Regular Expression
([^\n]*)\n\.and use this for the Replace part
$1.