Archive for category Visual Studio

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

, ,

13 Comments

Using unescaped paths in the Visual Studio Watch window

I am often debugging an app in Visual Studio and add a variable containing a file path to the watch window. I’ll usually want to open the file to verify the contents so I will copy and paste the path into a command window. This is really annoying because the pasted path doesn’t work due to the double backslashes. I have to spend time converting all the double backslashes into single backslashes in order for the path to work.

Here is a simple solution to this problem: In the watch window append “,nq” to the end of the variable in the watch window. This will automatically remove the double backslashes and quotations. Once that is done you can copy/paste the string into a command window and use it without modification.

Visual Studio Watch Window

, ,

No Comments