I am using Visual Studio 2010 with c#. I need to search my codebase for find all lines of code where two strings are found in the single line of code (the line of code could span multiple lines which c# allows). The two strings are not connected and I don't know what will be between them. I just want to find all occurances where it finds both strings in the line of code. Is there anyway to do this? Is there another tool outside of Visual Studio that would allow this type of search?
You can search multiple line text by pasting the text into the Find input box and Replace input box. Pressing Ctrl+Enter inserts a new line in the input box.
Ctrl + i - Incremental Search Most developers using Visual Studio are familiar with the “Find dialog” that you can launch by pressing the “Ctrl + F” key within the IDE.
To use Incremental Search, just press Ctrl+I and start typing. Your search term will appear in the status bar at the bottom of the screen and your search will update as you type. Press Ctrl+I again to move to the next result and Enter or Escape to end the search.
You can use the "Find and Replace" feature of Visual Studio to delete matching lines. The key is to match the whole line including the end of line character as well. You can do this in wildcard or regular expression mode. In wildcard mode, begin the expression with * and end the expression with *\n .
You can use regular expressions to search for files within Visual Studio - no need for external tools for this (though, of course, you can use grep
if you so wish).
See Using Regular Expressions in Visual Studio - the syntax is somewhat esoteric in that it doesn't conform to most regular expression dialects currently in use (it is different from the .NET one for sure).
Something like:
string1.+string2
Should work. If you need this in either order, try:
string1.+string2|string2.+string1
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