September 22nd, 2011

Visual Studio 11 Developer Preview: Find & Replace

In Visual Studio 11 Developer Preview we’ve streamlined and modernized our vast array of Find experiences.  Find and Replace is now a lightweight control within documents, delivering incremental search results as you type.  The Find and Replace in Files dialog has been simplified while at the same time gaining additional functionality such as Find Next and Find Previous.  Both Find experiences now let you use .NET Regular Expressions to perform complex search and replace operations, even across multiple lines.

The new Find and Replace Control

The new Find control sits at the top of the document as a search box. Ctrl + F now brings up this control, instead of the dialog. The new control affords all the capabilities of the dialog. You can Find Next, Find Previous, set Search Options, Replace etc.

image

Performing a simple Find

With the new Find control, you can perform a search exactly as you would with the VS 2010. Just hit Ctrl+F and type the search term. What you would notice however, is that now the search is instant and incremental. As you type, you get the matches highlighted and the first match selected by default. No need to click an additional Find Next button. Hit Enter to navigate among the matches in the document.

image Find Next

image Find Previous

Performing an Advanced Find

As I mentioned earlier, the new Find control affords all the capabilities of the Find Dialog. This means that you can search using advanced options (Match Case, Match whole word, Use Regular Expression) just the same as in the Find dialog. For this, simply click on the drop down next to the magnifying glass, in the search box. You can also hit Alt+Down when inside the search box.

image

Notice that setting Search Options acts like a filter instead of starting a new search. So if you searched for “Button”, without Match case, this would highlight all matches – button as well as Button. Checking Match case would filter this result set to only matches for Button (with the uppercase “B”)

MRU (Search History)

Find control maintains a history of the previously performed searches of up to five terms. This is displayed as a MRU (Most Recently Used) list. The list can be accessed by bringing up the dropdown from within the Find search box (or hitting the Alt+Down arrow key)

image

Performing a Replace

You can perform a Replace operation right within the new control. Just hit Ctrl+H / click on the drop down arrow to the left of the search box. This brings up the expanded version of the Find & Replace control. The replace box is below the Find box. Type your replace term and Hit Enter, or Atl+R or the Replace Next or Replace All buttons.

image Replace Next and Replace All

Changing the Scope

The Find control allows you to change the scope for Find & Replace operations. To change the scope, click on the Drop down arrow, as in the case of Replace. This brings up the expanded Find control with the scope selection dropdown.

image

“No Results” Alert

The Find control allows you to quickly find out when there are no results for the current search term with the current search criteria. When there are no results to show, the search box is highlighted with a red border indicating that there are currently no results to display.

image

Using Regular Expressions (.NET Regular Expression syntax only)

One of the major changes we have made, in response to customer feedback, with the new Find experience is moving away from the POSIX style regex syntax to .Net Regex syntax. You can do all your searches using the familiar .Net style regular expressions. The VS2010 style regular expression syntax has been discontinued. So, to search for a “Start Game”, I would type

In Visual Studio 11 Developer Preview: Starts+Game

In VS 2010 (This will not work in VS 11 Developer Preview): Start:b+Game

A complete reference for .NET Regular expressions can be found here .NET Regular Expression Cheat Sheet.

Find In Files Dialog

You can still do everything that you were used to doing with VS2010 Find Dialog with the new experience. To bring up the Find In Files dialog, simply hit Ctrl+Shift+F (or Ctrl+Shift+H for replace). This brings up the familiar dialog. We have simplified this dialog to a large extent. There are just 2 tabs – Find In Files and Replace In Files.

image Find In Files

Now there are only two tabs – Find In Files and Replace in Files. We have added Find Next and Find Previous. Note that you can also bring up the Find In files dialog from within the Find control, in the Search Options dropdown.

Find Symbol has been discontinued

With the new Find experience we have relooked at the Find dialog and redesigned it for simplicity. Based on the usage data we have received from our Customer Experience Improvement program, the Find Symbol features was rarely ever used by our customers. With the new Find, the support for Find Symbol has been removed from the UI. However, you can still search for symbols using the Find All References from within the Editor.

Find & Replace Cheat Sheet

You can of course use the same short-cuts and accelerator keys that you are used to with the Find dialog, with the Find control. Here is a list of shortcuts and accelerator keys you can use to work with Find & Replace in Visual Studio 11 Developer Preview.

Shortcuts:

Command VS 11 Developer Preview Action Command
Ctrl+F New Quick Find Edit.Find
F3 Find Next Edit.FindNext
Shift+F3 Find Previous Edit.FindPrevious
Ctrl+F3 Find Next Selected term Edit.FindNextSelected
Ctrl+Shift+F3 Find Previous Selected term Edit.FindPreviousSelected
Ctrl+I New Quick Find / Forward incremental search Edit.IncrementalSearch
Ctrl+Shift+I New Quick Find / Reverse incremental search Edit.ReverseIncrementalSearch
Ctrl+Shift+F Find in Files Edit.FindInFiles
Ctrl+Shift+H Replace in Files Edit.ReplaceinFiles
Ctrl+H Quick Replace Edit.Replace
Enter Find Next Edit.FindNext
Shift+Enter Find Previous Edit.FindPrevious

Accelerator Keys:

Shortcut VS 11 Developer Preview Action
Alt+F Find Next, Find All (buttons)
Alt+R Replace, Find Next
Alt+A Replace All (button)
Alt+I Skip File (button
Alt+C Toggle Match Case
Alt+W Toggle Whole Word
Alt+E Toggle Regular Expressions
Alt+N Focus in Find What Box
Alt+P Focus in Replace With Box

We want to hear from you!

Because Find is such a critical and integral part of the Developer experience, we need your feedback on how well the new experiences are (or are not!) working for you. We are listening to your feedback.

If you have any additional questions, feel free to leave comments below.  If you’re experience problems with Find & Replace, please file a Connect Bug, and we’ll investigate

You can write to us here: VSFindFeedback2@microsoft.com

You can also send your feedback from within the Find control:

image

Thanks, Murali Krishna Hosabettu Kamalesha Program Manager – Visual Studio Code Experience

Known Issues

As you might imagine, with the new release, we have completely revamped the Find experience for our customers. With this huge change, there are some known issues and unfortunately we didn’t have time to fix by the time of this release of Visual Studio 11 Developer Preview. However, these issues are already fixed in internal builds and you would be able to get these when you install a subsequent release J.

Unable to Find All with the Current Document scope

In the current version, you will not be able to perform a Find All when the scope is current document. However, when you search for a term using the new Find Control, all of the matches in the current document are highlighted. This should hopefully allow you to work around this issue. And like I mentioned, this issue has been fixed for a subsequent release.

Find in Files does not clear the Find results

In the current version, when you perform a Find in Files, the results are appended to the Find Results window. The results of the previous search are not cleared. To work around this issue, you can still clear out the Find Results window manually. We understand this is inconvenient and this has been fixed, but you will have to wait for a subsequent release. J

Search Criteria is missing from the Find Results window

When you perform a Find All operation, the search results are populated in the Find results window. In the current version, the results are still populated, but a line mentioning the search criteria is missing. For subsequent releases, this issue is also fixed.

Topics
.NET

Author

Visual Studio has been around since 1997 when it first released many of its programming tools in a bundle. Back then it came in 2 editions - Visual Studio Professional and Visual Studio Enterprise. Since then the family has expanded to include many more products, tools, and services.

0 comments

Discussion are closed.