I've become rather fond of the "Find-And-Replace" function in Visual Studio. The function lets me replace phrases, words, symbols, or whatever you can type into the textbox on the screen.
How can I make it replace a character with a newline?
I've become rather fond of the "Find-And-Replace" function in Visual Studio. The function lets me replace phrases, words, symbols, or whatever you can type into the textbox on the screen.
How can I make it replace a character with a newline?
According to Helixoft: Multiline Search and Replace in Visual Studio
you can enable Regular Expressions and then use \n to indicate a new line.
Select text. Select the little asterisk control immediately to the right of the whole word control, to enable regular expressions. Enter \r\n into find box Enter replacement into "Replace..." Replace all (or replace next)
If you want to replace a character with a newline, chances are you might also want to replace a newline with a character, or a whole string containing a newline with another string.
I just tried doing this with Visual Studio 2022, and \n in the search pattern did not work. Visual studio kept saying that the regular expression was malformed, but it would not say exactly what the problem was. Extremely frustrating.
So, here is what worked for me:
\s.().)).!) or any other special symbols..$ to mark the end of the line in the search pattern, not \n.