Posts Tagged vs2008tips

Multi-line Search and Replace in Visual Studio

Often it is useful to do a global search and replace in a directory of files. For a search string on a single line this is trivial. Just hit Ctrl-Shift-H or “Edit -> Find and Replace -> Replace in Files”. Then enter the necessary information and do the replacement.

It becomes more tricky when you have a multiline search or replacement string. With the standard options in the search and replace box you can’t do this. But select Regular Expressions in the Find Options section and a multi-line string becomes possible.

Now you can use Regular Expressions in the search. Enter your search and replace string as normal but enter ‘\n’ where you want a newline to appear. Visual Studio can now find and replace multi-line strings!

Multi-line search and replace

, ,

8 Comments