Visual Studio 11 Developer Preview: Find & Replace

Visual Studio 11 Developer Preview: Find & Replace

Rate This
  • Comments 51

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: Start\s+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.

Leave a Comment
  • Please add 2 and 8 and type the answer here:
  • Post
  • Find in a specific directory and below appears to be broken in the find in files dialog. Whenever I selected a directory by typing in the combo it appears to work, but it just jumps to another scope when the combo box loses focus.

  • So, as I imagined, the only .NET alternative to the :i search is to type (and remember) \b(_\w+|[\w-[0-9_]]\w*)\b

    That's A LOT of extra typing just to find an identifier.

  • Hello again!

    Thank you for your posts. Your feedback helps us tailor the experience for our customers. Keep them flowing :)

    I will answer to these questions separately.

    1. Number of items in the MRU (Most Recently Used) List

    The Find dialog displays up to 20 MRU items. In the Find control, the     options reside below the MRU. We have capped the MRU to allow users to quickly get to these search options with the down arrow key.

    We will continue to refine the Find control in this and future versions.

    2. Find and Replace on UI thread

    We have made some perf changes in Find.  In particular, we’ve moved the highlighting of results to the background thread while you interact with the IDE. We’ve heard the feedback on performance and so we’ll continue to work at improving find performance in this and future versions.

    3. Shortcut to close the output window.

    Shift+Esc is the shortcut to close the output window.

    4. For all your queries on Visual C++, the best place to start is with the Visual C++ Team blog - http://blogs.msdn.com/b/vcblog

    Thanks again for writing to us! If you think of anything else while you are using the new Find, please do let us know.

    Murali Krishna Hosabettu Kamalesha  •  Program Manager •  Visual Studio Editor  

  • It would be great if there was an option to permanently surface the frequently used Match Regex, Match Whole Words, and Match Case options so that you could know at a glance which options are selected.  If there was an option to expand the quick find box so that these options always show up off to the side or in a second row below that would make searching easier.  If you need to condense it for space, the UI could read something like: "Match: [x]Regex [x]Whole Words [x]Case".  But it would be great if there was a way to make these always default to visible.

    Also it seems like the new search box doesn't work that well when you want to just Search/Replace within a selected block of code.

  • We should be able to cycle through the MRU search history with the Down key (without requiring us to hit Alt+Down to drop the list).

  • Find, control sitting in document instead of dialog! looks good...

  • For some reason I can't get \n to work for a replace. In other words, I have "Testing" in my document. The search string is "ing". My replace string is "\n". I end up with "Test\n" What happened to the ability to replace to a CR, Tab or other? How can I support this in other ways? Even WinWord allows a S@R to add CR/LF.

  • Hello,

    Hope you all had a great Holiday season. Happy New Year!

    Thanks again for your posts. We are glad to hear you like the placement of the control inside the document better than the dialog. We have heard feedback from our users asking for the ability to cycle through the MRU using the down arrow key. This had not been built at the time of the Developer Preview. The good news is that we have already added this feature in our internal builds and you should be able to hit the down arrow key and cycle through the MRU. You are right, the new line replace does not work in the Developer Preview. This is a known issue which we have already fixed in our internal builds. Find control should allow you to perform replaces with “\n”.

    We have considered feedback from our users and have made significant improvements to the Find experience in Visual Studio, post the Developer Preview. Stay tuned for upcoming versions!

    Thanks,

    Murali

    Murali Krishna Hosabettu Kamalesha • Program Manager • Visual Studio Editor

  • what customer feedback told you to get rid of POSIX regular expressions? The only feedback I can see on the issue says the opposite...

  • @Iain

    AFAIK Visual studio has never implemented the posix regular expression syntax.  It's always been a heavily customized syntax, quite different from POSIX.  The blog post is in error in this detail.  Not to mention that it's very easy to get VS stuck in an (almost) infinite loop with regexes.

  • Can you please make the document scope for Find (CTRL-F) not share the same scope as Find in Files (CTRL-SHIFT-F)!   It is really annoying to have to consistently change scope.  For Find in Files I nearly always want the "Entire Solution" scope.  But for Find I nearly always want just "Current Document".

  • Can you please make the document scope for Find (CTRL-F) not share the same scope as Find in Files (CTRL-SHIFT-F)!   It is really annoying to have to consistently change scope.  For Find in Files I nearly always want the "Entire Solution" scope.  But for Find I nearly always want just "Current Document".

  • Simon.B1 hit it on the head - 'Find' (Ctrl-F) is almost always for 'find in document' but 'Find in Files' should always search *files*, not just 'Current Document' or whatever the scope is set to.

    Overall, I really like the changes to the Find dialog (especially getting out of the way), but constantly getting no results and then remembering I have to manually change the scope is not productive for me.  That is really my only criticism of the new changes.

  • Cool !

  • how to create a thread in vs 2012  in c# ?

    I tried by including   using System.Threading; namespace but it is showing error. pls... help me in solving this

Page 3 of 4 (51 items) 1234