Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2012: How to handle code replacement over multiple lines

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.

search/replace box layer in Visual Studio 2012 (german language pack)

In the "embedded" search box there is also only a single-line input field: embedded search/replace box in Visual Studio 2012 (german language pack)

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?

like image 835
Herr_Schwabullek Avatar asked Mar 11 '13 11:03

Herr_Schwabullek


People also ask

How do I create a new line in Find and Replace in Visual Studio?

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 .

How do you find and replace multiple lines in Notepad ++?

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.


1 Answers

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

find replace example

like image 84
Lanka Avatar answered Nov 08 '22 19:11

Lanka