I often have to replace multiple lines in multiple documents. In Visual Studio 2012 there seems to be the possibility to put muliple line code in a simple one-line-input-box only.
In the "embedded" search box there is also only a single-line input field:
After inserting the often very long search terms and trying to put a regular expressions for line breaks into it, i have to move horizontally inside a one-line-input-field which isn't comfortable at all.
Is there another way to use the find/replace functionality for replacing muliple lines in Visual Studio 2012?
In the local searchbox ( Ctrl + F ) you can insert newlines by pressing Ctrl + Enter . If you use the global search ( Ctrl + Shift + F ) you can insert newlines by pressing Shift + Enter .
It's easy to do multiline replace in Notepad++. You have to use \n to represent the newline in your string, and it works for both search and replace strings. You have to make sure to select "Extended" search mode in the bottom left corner of the search window. This is in a file already open.
In order to replace multiple lines first you have to check regular expression option on search window. In following example it's search the
first
second
third
and replace it with
fourth
fifth
sixth
search text : first([\s\n])second([\s\n])third
replace text : fourth$1fifth$2sixth
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With