Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Visual Studio 2013 Cookbook
Visual Studio 2013 Cookbook

Visual Studio 2013 Cookbook: Understanding the latest features of Visual Studio can speed up and streamline your projects. And there's no better learning tool than this collection of focused recipes that gives you the fast, hands-on experience you need.

eBook
€19.99 €28.99
Paperback
€37.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Visual Studio 2013 Cookbook

Chapter 1. Discovering Visual Studio 2013

In this chapter, we will cover:

  • Synchronizing settings

  • Touring the VS2013 IDE

  • Project round-tripping

  • Managing the editor windows

  • Finding Visual Studio commands

  • Searching and navigating

  • Navigating in depth

Introduction


The arrival of Visual Studio 2013 (VS2013) marks the continuation of Microsoft's desire to produce more frequent updates to the Visual Studio platform. If you are coming to VS2013 from VS2012, you will find a more familiar appearance. Users upgrading to VS2013 from VS2010 will find greater differences and need to spend a bit more time learning the new interface. This chapter will provide a walk-through of the major changes and explain how VS2013's IDE will benefit you, regardless of the languages you are programming with.

VS2013 has focused a great deal on improving the usability and the power of the editor and surrounding windows that you use every day in your work. Before exploring specific features that apply only to certain areas, this chapter examines how the IDE can benefit your work regardless of whether you write C++ console applications or use JavaScript to write Windows Store apps.

The goal of this chapter is to provide you with an overview of the IDE-related features of VS2013. The chapter will begin by describing the integration of Microsoft accounts with the IDE and the value that this can provide. Next comes a review of the IDE, with a focus on the new features found in VS2013. Realizing that in the real world, circumstances can require supporting pre-VS2013 projects, we'll look at how Visual Studio utilizes project round-tripping to enable working with these older project types. The chapter will then wrap up with a couple of recipes on day-to-day editing and navigation tips designed to increase your productivity. Like any set of complex tools, an initial investment in learning the nuances can provide lasting dividends.

Synchronizing settings


One of the first things that you will notice upon opening VS2013 is the request to log in with a Microsoft account. You can use any existing Microsoft account that you have, including Outlook/Hotmail, OneDrive (formerly known as SkyDrive), and Xbox Live. If you have an MSDN account, Microsoft recommends that you use it to log in to Visual Studio. If you don't, or if you would prefer to use a new account, you can create one at https://login.live.com/. Microsoft groups the settings by product type, so there is one set of roaming settings linked to all editions of Visual Studio Professional, Premium, and Ultimate. A separate set of settings is synched across the Express editions of Visual Studio. The result is that the settings saved for VS Express 2013 for Windows will not sync when you log in to VS2013 Professional.

In this recipe, we will look at how this synchronization works and what it will coordinate on your behalf.

Getting ready

To explore, launch your copy of Visual Studio 2013.

How to do it…

If you are not prompted to sign in at startup, you can always sign in from within Visual Studio. The arrow in the following screenshot indicates where the Sign in option is located:

Currently, VS2013 will sync options from the following categories:

  • Environment : This section consists of several subitems:

    • Fonts and Colors: This includes preferences for the text used throughout the editor

    • Color theme of IDE: This provides built-in themes including light/dark/blue

    • Keyboard: This includes user-defined keyboard shortcuts and the selected keyboard-mapping scheme

    • Startup: This indicates what should display when VS2013 opens

  • Text Editor: A multitude of settings including tabs versus spaces, word wrap, scroll bar placement, and so on

  • Environment Aliases: (Not shown, applies to premium versions only) Commands defined in the command window (Ctrl + Alt + A)

    The following screenshot highlights the synchronized categories:

Tip

The Options dialog box in VS2013 has a couple of usability enhancements. First, it has its own integrated search box (once Options is opened, the hotkey is Ctrl + E) for specifically searching within the Options dialog box. Second, the dialog is now resizable, making it much more useful for viewing settings that have lengthy configuration options.

How it works…

Microsoft stores a copy of your settings on their servers. A constant Internet connection is not required to use Visual Studio, but your settings will not synchronize until you are reconnected. If a connection is not available, you cannot login until Internet access is restored, but Visual Studio will still be usable. Taking it one step further, VS2013 remembers if you were logged in the last time when you closed the program, so your last known settings will be available as they are stored locally.

There's more…

All synchronization options are configurable by navigating to Options | Environment | Synchronized Settings, and you may opt to have any combination of the preceding categories synched. This configuration of settings is specific to each machine and does not transfer. By default, VS2013 will attempt to synchronize all settings if you are logged in with a Microsoft account.

Touring the VS2013 IDE


The user interface in VS2013's IDE has several differences from VS2012 and the previous versions of Visual Studio. Let's take a look at what is available in this recipe.

Getting ready

All you will need for this recipe is a copy of VS2013 so that you can follow along with where different options are located. The following screenshot provides an overview of what will be covered:

The legend for the highlighted items in the preceding screenshot is as follows:

  • The user's account entry/selection is indicated with 1

  • The notification center is indicated with 2

  • The Feedback menu is indicated with 3

  • The scrollbar thumbnail is indicated with 4

  • CodeLens (Ultimate only) is indicated with 5

  • The editor window controls are indicated with 6

How to do it…

Over the next few pages, we are going to take a firsthand look at the new areas of the Visual Studio IDE. You may follow along with your own project or use the sample project where indicated.

Feedback

This screenshot shows the choices available when the Feedback menu is accessed by clicking on the chat balloon (far left icon):

Indicated by a chat balloon, the feedback icon provides an immediate way to send feedback to Microsoft from within VS2013. When the chat balloon is clicked, a drop-down list appears, allowing you to select from either Send a Smile (indicating a positive commentary) or Send a Frown (indicating negative commentary). Functionally, there is no difference in the dialog box that appears, but the choice of a smile or frown allows you to provide context for your remarks so that there is no ambiguity in your message. Each option allows you to include an e-mail address so Microsoft has a way to respond, and the frown option has an additional checkbox to indicate whether or not your comments are describing a bug.

The menu also provides the ability to report a bug and access the MSDN forums within Visual Studio. Both options provide a quick way to accomplish these tasks so that you make a report or seek help and get back to coding with minimal distractions.

Notifications

Between the Feedback icon and the Quick Launch field is the flag icon representing notifications:

In the preceding screenshot, you can see that one update is pending. The notification flag is designed to provide an unobtrusive alert when updates to VS2013 and the installed packages are available. Notifications listed in the sidebar are color-coded with yellow and red, which are used to indicate medium and high priorities respectively. Examples of notifications that could appear include notices about updates to Visual Studio, updates to installed extensions or samples, or notices alerting that the trial period is ending. Notifications may be dismissed en masse, and once they are dismissed they do not reappear.

User account

If you have signed in to VS2013 with a Microsoft account (see the Synchronizing settings recipe), this area displays the graphical avatar along with your account's display name. The following screenshot shows the difference in the display that occurs when you log in:

It also provides a way to sign in if you have not done so, or if you wish to change the active account being used. In the preceding screenshot, the left-hand side has the text Sign in, and a grey icon indicates that the user has yet to login. On the right-hand side, you can see the difference when the user has logged in, as the username has replaced the Sign in text, and the gray icon has changed to reflect the user's avatar (which in this case is a green icon overlaid with the white initials of the user's name).

Scroll bar thumbnail

The scroll bar has expanded its usefulness in VS2013. You can now customize it to show your overall position in a source file, and provide a tool tip that lets you examine code elsewhere in your current file without changing your current location. The new option is called map mode, as opposed to the historical behavior that is called bar mode (which is the traditional scrollbar appearance and behavior). All aspects of the map mode are customizable, including whether it appears at all, its width (narrow, medium, or wide), and the ability to show the preview tool tip.

The following screenshot shows these features in action:

The preceding screenshot shows the scroll bar configured to be in map mode. The first arrow (marked as 1) indicates that what is being displayed in the editor is located relative to the overall source file. The second arrow (marked as 2) is pointing to the preview tool tip that appears when your mouse cursor hovers over the scroll bar.

The scroll bar's pull down feature remains. When it's used to split the main window, it allows for two independent viewing panes of the same file, and each can have their own independent vertical scroll bar. In the split view mode, both vertical scroll bars share the same options (width, bar mode versus map mode, and so on).

The following screenshot lists all of the options available for configuring the scroll bar's functionality. It can be accessed directly by right-clicking on the vertical scroll bar and selecting Scroll Bar Options…. Alternatively, it is accessible in VS2013's main Options dialog box by navigating to Tools | Options, with the scroll bar settings listed under Text Editor | All Languages | Scroll Bars. For additional customizations, you may set the language (C++, C#, and so on) settings for the scroll bar in the Options dialog box if desired:

Peek Definition

Visual Studio has had the Go To Definition (F12) option for several versions now. When we right-click on a method, or move the cursor to it, selecting the Go To Definition option will automatically bring you directly to the file with the corresponding definition. While you can easily navigate back and forth with (Ctrl + -) and (Ctrl + Shift + -), sometimes changing the open file is not what you would like to do. Enter Peek Definition (Alt + F12). This allows you to select a method and look it up, but instead of switching to the appropriate file, VS2013 will create a mini-window within your current editor. The following screenshot shows the results of using the Peek Definition option on the ConfigureAuth() method:

Sequential peeks can be performed, each opening via a tabbed interface. Navigation between these tabs (represented by circles) can be done via the mouse or keyboard: peek forward (Ctrl + Alt + =) and peek backward (Ctrl + Alt + -). The Peek Definition window uses the same scroll bar behavior as that of the parent editing window, and this behavior can be changed in either window by right-clicking on the scroll bar and selecting Scroll Bar Options....

CodeLens (Visual Studio Ultimate Only)

CodeLens, also known as code information indicators, is a feature specific to VS2013 Ultimate. Activated by default, CodeLens provides real-time meta-information about the file you open in your main editor window:

As illustrated in the preceding screenshot, shown inline with your code will be light colored term references, and the results of executed tests for each method/function as marked by the passing term. The references term indicates the number of places a method is used, and can also display a pop-up window on a mouse over that shows where it has been used. Likewise, the passing term relays the unit test results inline. While working with projects checked out from Team Foundation Server (TFS), CodeLens will also display the most recent author of the method in question. Clicking on that name will pop up a details window listing the change history.

If you would prefer to keep your hands on the keyboard, holding down Alt will bring up hotkeys that can be used to select among the features discussed earlier. The following screenshot illustrates these options, with Alt + 2 opening a pop-up dialog box listing references for the selected method and Alt + 3 listing details about unit tests. The display options for CodeLens are labelled as Code Information Indicators in the Options dialog box and can be found under Text Editor | All Languages | Code Information Indicators:

Code Maps (Visual Studio Ultimate Only)

VS2013 Ultimate continues the use of a code visualization tool that Microsoft calls Code Maps to provide a representation of the open project. The following screenshot shows Code Maps in action:

Code Maps can be created and used in VS2013 Ultimate, but VS2013 Premium and VS2013 Professional can only consume them. However, users of Premium and Professional can interact with the maps and add comments/flags as they are reviewed. Code Maps can be activated in an editor window via Ctrl + `, which is Ctrl plus the backquote key (typically found sharing a key with tilde). It can also be called by right-clicking in the editor window on a particular method or class that you want to map.

Once generated, the map may be manipulated in several ways, including zooming and the ability to expand to show related elements. Individual elements may be double-clicked so that they are brought up in the code editor for closer analysis. An element may also be right-clicked when in the Code Map for further navigation options (Go To Definition, Show Base Types, and so on) or to be commented on. This is particularly helpful for large or complex code bases where a map can assist in comprehension by visualizing the relationships and adding commentary external to the source code.

The Code Map indicates your position from the active editor window on the map with a green arrow icon. In the preceding example's screenshot, the editor is in the Vehicle class, which is pointed to on the Code Map by the green arrow.

See also

Project round-tripping


If you would like your .NET-based projects to be compatible with the previous versions of Visual Studio, be sure to choose a version of the .NET Framework that they support. For example, if you would like your project to support VS2010, be sure to target .NET 4.0, as .NET 4.5 is not compatible. Round-tripping is useful for situations where not all members of a development team have VS2013, as well as for situations when you wish to tread lightly on older projects.

Tip

As a friendly reminder, be sure that both versions of Visual Studio are up-to-date while sharing projects between VS2012 and VS2013. As noted in the While you were gone section of the Preface, this means Update 4 should be applied to VS2012.

In this recipe, we will discuss how projects can be shared across Visual Studio versions and a few details about how projects are handled.

Getting ready

The default .NET Framework in VS2013 is 4.5, so it is very easy to create a project that cannot open in VS2010. If you are not using any features specific to 4.5+, it is merely a matter of changing the project's properties to target 4.0. Keep in mind that some features will not be supported outright, but will be gracefully ignored.

Round-tripping is useful for a number of reasons. While supporting legacy projects, it is usually preferred to alter the existing code as little as possible. The support for older projects means that you can use VS2013 to edit them without keeping a copy of VS2012 installed. It also provides a way for users of VS2013 to work with fellow developers who are yet to upgrade from VS2012.

How to do it…

The best practice is to test upgrading on a backup of your legacy project. This way, you have an easy way to return to the status quo in the event of a failure or complication. Most projects will simply open without any complaint, especially those from VS2012 and, to a lesser extent, VS2010. If Visual Studio doesn't object, it is simply a manner of opening your old project in VS2013 and getting to work. Upon making edits and checking your code (if necessary), fellow developers running VS2010/VS2012 will have no difficulty making their own contributions.

How it works…

Visual Studio uses solution files to store details about the projects and solutions you create. Ending with the .sln extension, these files help Visual Studio manage your project. For example, a solution created in VS2012 has the following header at the beginning of its SLN file:

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012 

By comparison, a solution created in VS2013 has this header as follows:

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.20623.1 VSUPREVIEW
MinimumVisualStudioVersion = 10.0.40219.1

Note

The initial blank line is intentional for both examples.

The third line (prefaced with #) indicates the "human-readable" version of Visual Studio used to create the project. VS2013 projects add two additional lines to this header as shown in the preceding code snippet. The fourth line shows VisualStudioVersion, which specifies the full build version of Visual Studio used, while the fifth line lists the value MinimumVisualStudioVersion, which indicates the minimum version of Visual Studio that can be used to open the project.

Tip

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

There's more…

Not every project type supports round-tripping, as some require specific changes to be made in order to run under VS2013. Some notable project types and their exceptions are as follows.

Windows Store applications

Windows Store apps have some special requirements. Apps targeting Windows 8.1 require VS2013 and the underlying OS to be Windows 8.1. VS2013 can work with existing Windows 8 store apps if they were created by VS2012. As previously noted, Windows 8.1 will quickly replace Windows 8, so all new apps should target that platform.

The Model-View-Controller (MVC) framework

Visual Studio 2013 brings support for MVC 5 in addition to supporting MVC 4, while Visual Studio 2012 only supports MVC 3 and MVC 4. Visual Studio 2010 SP1 only supports MVC 2 and MVC 3. These limitations dictate whether or not your project will upgrade. However, there are tools and guidance on how to migrate your application to a newer version of MVC. Upgrading an MVC 2-based application to MVC 3 can be done with the standalone upgrade from CodePlex at http://aspnet.codeplex.com/releases/view/59008. Once this is completed, Microsoft provides guidance on upgrading the application from MVC 3 to MVC 4 at http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253806. Unfortunately, the upgrade from MVC 3 to MVC 4 is a manual process.

MSI setup (.vdproj)

This project type refers to Visual Studio Installer projects, which are not supported in VS2013.

Upgrading an existing project

Depending on the nature of the solution or project you are working on, Visual Studio may require you to convert your project. You will be prompted to make a conversion decision, as shown in the following screenshot:

Tip

If you decide not to upgrade the project, you may do so later via Project | Upgrade Solution. As you may expect, the best practice is to perform a trial conversion on a copy of your solution in the event of something going wrong.

Creating a new project

Starting a new project in VS2013 remains unchanged from previous versions, but some of the available choices have changed. If you have not previously updated VS2012, one of the changes to notice is that VS2013 offers .NET Framework 4.5.1 as a framework that can be targeted. Some other new choices include templates to create apps for SharePoint and Office, as well as Python-based projects. See the Project round-tripping recipe for important considerations while creating projects that are destined to be edited in different editions of Visual Studio.

Managing the editor windows


One of the advantages of using a graphical IDE is the ability to have multiple windows open, and learning how to customize their size and layout in Visual Studio is important for maximizing their productivity. Given the multitude of windows (editors, debugger output, and so on) Visual Studio has open, it can be helpful to learn how to place them where you want so that you can focus on your work without being slowed down by clutter.

Tab pinning allows you to mark individual windows so they stay open while you navigate through the editor. Previewing documents is a useful way to navigate across several files without cluttering your tabs with several open documents. This recipe will explore both options.

Getting ready

Open either the VS2010_Web sample solution or use a solution of your choice. Ensure that the Solution Explorer window is open.

How to do it...

The following steps will show how the position of open windows can be positioned to your liking. Let's get started:

  1. In the Solution Explorer window, locate the Default.aspx.cs file in the VS2010_Web project and double-click on it. The source file will open in the main window area as in the previous versions of Visual Studio. However, you will now notice that the document tab features a pin icon next to the tab name, as you can see in the following screenshot. You'll use that pin in just a few steps:

  2. Using the Solution Explorer window, open both the About.aspx.cs and Global.asax.cs files by double-clicking on them. You should now have three documents open with their tabs showing in the tab well (this refers to the row of tabs for each open document in the editor), as shown in the following screenshot:

  3. Click on the Default.aspx.cs tab to select it and then click on the pin. The pin will change to point downwards indicating that the document is now pinned. Visual Studio 2013 will always keep pinned tabs visible in the tab well. These pinned tabs will remain visible even when Visual Studio needs to start hiding unpinned tabs to save screen display space. The pinned document tab will be moved to the left next to any other pinned documents you may have open, as shown in the following screenshot:

  4. Right-click on the Global.asax.cs document tab and click on the Close All But This option to close all open documents except for the one currently selected. This will include closing any pinned documents, which are shown in the following screenshot:

    Note

    There is a related option: Close All But Pinned. This is useful when you would like to only keep pinned files open.

  5. Reopen both the Default.aspx.cs and About.aspx.cs files that you closed by double-clicking on them in Solution Explorer.

  6. One of the usability problems with document tabs in Visual Studio 2010 was that you could accidentally float documents by double-clicking on a document tab.

  7. In Visual Studio 2013, this behavior has changed. Double-click on a document tab of your choice and notice how Visual Studio sets the focus to this tab instead of floating it. (This is the same behavior as single-clicking on a document tab.)

  8. Press Ctrl + Shift + F to open the Find in Files dialog box. Enter the class in the Find what field and ensure Look in is set to Solution, then click on the Find All button.

  9. In the Find Results 1 window, select a result from the ChangePassword.aspx file.

  10. The file will open in the preview tab, located on the right-hand side of the tab well.

  11. The preview tab shows the contents of the currently selected document if it is not already open. In the Find Results 1 window, select a result from the Login.aspx file. It will now be opened automatically in the preview tab, and the ChangePassword.aspx document will be closed.

  12. Assume you now want to keep the Login.aspx file open for a while. Either click on the Keep Open icon on the tab or change the contents of the file. Any document in the preview tab that is changed is automatically promoted to a normal tab.

Visual Studio will move the document from the preview tab area into the main tab area. The color of the tab will also be changed from purple to blue indicating that the tab is now a normal document tab.

How it works...

Pinning documents works much like pinning does in any other part of Visual Studio, and is very handy for keeping the documents that you are working on regularly within easy reach, especially when you have many documents open at once.

The preview document tab is a great way to prevent tab clutter and becomes very useful while debugging deeply nested code. You may recall that Go To Definition as one function that uses the preview document tab. For example, multiple source files may be opened as you trace a program's operation across methods and classes. The preview document tab helps you cycle quickly through these files while preventing the tab well from filling up with documents that aren't needed for more than a few moments.

There's more...

As always, there are ways to customize the behavior of the document tabs in Visual Studio.

Single-click preview in Solution Explorer

The preview tab isn't restricted to just the Find Results window. It can also be used from within the Solution Explorer. If you activate the Preview Selected Items button in the Solution Explorer toolbar, then every item you click on will automatically be opened in the preview tab. The Preview Selected Items button is a toggle button (shown in the following screenshot). If you want to disable the behavior, you only need to click on the button to deselect it and the preview behavior will be turned off:

Customizing tab and window behavior

Navigating to Tools | Options in Visual Studio will show the following dialog box:

There are a number of options here that let you control how the tabs behave. With Visual Studio 2010 Productivity Power Tools, many developers found different ways to configure their tab well to get the experience they wanted, and while not everything from the power tools came across to the final Visual Studio 2012 product, a number of features most certainly did. Feel free to experiment with the Tabs and Windows settings to get Visual Studio working the way you like it most.

Finding Visual Studio commands


The goal of the Quick Launch box is to provide a keyboard-friendly way of accessing the extended features of Visual Studio without needing to clutter the central interface. Keyboard shortcuts are a great way to speed up tasks, but it can be difficult to learn and remember while first starting out, or while exploring a new area of Visual Studio. The Quick Launch option addresses this by providing a way to locate different areas of the program, learn keyboard shortcuts, and provide a keyboard-centric way to access commands.

Getting ready

Simply start Visual Studio 2013.

How to do it…

To try it out, start by pressing Ctrl + Q, then begin typing the topic/subject that you are looking for, as shown in the following screenshot:

What is important to notice is that Quick Launch can do even more than what may be obvious at first glance. In this example, notice that open was the term entered as a search term. Quick Launch produces a list of results to this query, grouped by the following categories: Menus, Options, and NuGet Packages. As you can see, this list of results is more than just commands, it also includes various areas in the Options dialog as well as NuGet Packages.

You can immediately navigate through the search results with the arrow keys on the keyboard if the desired result is immediately available. You can access a command directly from this list, and where available, the accompanying keyboard hotkey for a command will be listed. In this way, you can learn new shortcuts while doing your daily work.

In the next example, jquery was entered into Quick Launch, producing a list of results that includes context-specific File menu commands (Save and Save As), the option to switch to an open editor window with jquery in the file name (jquery.ui.autocomplete.min.css), or to search NuGet for packages using jquery as the search term.

The following screenshot is showing the availability of these various options:

There's more…

The Quick Launch option can go further. Let's return to the results of the open term. Note that at the bottom, the Quick Launch option indicates that Ctrl + Q can index through additional views. Additional presses of Ctrl + Q will toggle the list of results to show only results from an individual category, in this case Menus, Options, or NuGet Packages. A final press of Ctrl + Q will return to displaying all of the available results. The ability to toggle through categories is particularly useful when your Quick Launch list is lengthy and you would like to ignore unnecessary categories that are cluttering the list of results. Pressing Esc once will clear the search results in Quick Launch, and pressing Esc again will return you to the open file in your editor.

Tip

Using the Command Window / Command Aliases

The Command Window (accessible via Ctrl +Alt +A and available on premium editions of VS2013) allows you to keep your hands on the keyboard while quickly accessing commands via an integrated command prompt window. As Microsoft ships Visual Studio preloaded with command definitions, entering an alias will display all of the currently defined commands, and the alias cmd action (where cmd is the desired name of your alias and action defines what should happen) will allow you to define your own. You can see from the following screenshot that typing bl is much faster than typing Debug.Breakpoints. Note that by default, command aliases are stored as part of your synchronized profile:

Searching and navigating


Visual Studio provides many ways to make maneuvering through your code easier and more efficient.

Getting ready

To best see this in action, open a project that has multiple files available for editing. This can be the sample project or one of your own choice. Once it is open, simply open a couple of source files.

How to do it…

Pressing Ctrl + Tab provides easy access to a couple of different ways to navigate around Visual Studio. If Ctrl + Tab is pressed and immediately released, Visual Studio will alternate between the two most recent files that you have opened in the editor window. This provides a quick way to move back and forth. If Ctrl + Tab is pressed and Tab is released, a pop-up window will appear. Continue to hold down Ctrl when it appears, and then arrow keys can be used to maneuver around the list of all active files and windows. To make a selection, either release Ctrl while highlighting the desired target, or while holding Ctrl, press Enter. This is shown in the following example's screenshot, where active files currently open in Visual Studio are shown in the right-hand side column, while open tool windows are shown in the left-hand side column:

There's more…

If you would rather take a hybrid (mouse + keyboard) approach, the window Ctrl + Tab produces also supports selection by mouse. Start in the same manner as done earlier in this recipe, holding down Ctrl + Tab to bring up the window. Release Tab while holding down the Ctrl key and then use your mouse to left-click directly on the file you would like to switch to.

Quickly searching your code

Searching a project file to find specific strings of text is a common daily task performed by developers. Visual Studio tries to make this easy by offering specific tools to find and replace text at various levels of your code base. Several options are available under Edit | Find and Replace, including Quick Find, Quick Replace, Find In Files, and Replace In Files.

Tip

The Incremental Search option (Ctrl + I) is a quick way to search within the file you are currently editing. When activated, a Find dialog box appears in your active editor window, allowing you to enter search terms.

The Quick Find (Ctrl + F) and Quick Replace (Ctrl + H) options share a common dialog box. Both provide the ability to search the current code block, the current project, all open documents, or the entire solution. If your search options include the file that's currently open, the vertical scroll bar will highlight any matches found. This provides quick visual feedback on the frequency of a search item:

Another feature that Quick Find and Quick Replace share is the ability to set the following search options: match case, match whole word, and whether or not regular expressions can be used. The use of regular expressions allows for more complex queries to be used, allowing users to extract more detailed information from their searches.

The Find In Files (Ctrl + Shift + F) and Replace In Files (Ctrl + Shift + H) options provide a more advanced method of conducting searches across a code base. They expand on the functionality offered by the quick tools by allowing you to specify certain file types that should be searched (for example, all HTML and JavaScript files) and provide the ability to display the results of an operation in a separate window.

In the preceding example's screenshot, a simple regular expression was used to search the entire solution using the specified file mask. The results were outputted to Find Results 1, which is a live window. This means that you can click on a line with a particular search result and you will go directly to that file where the match was made.

Navigating in depth


The Solution Explorer window that we were accustomed to in Visual Studio 2010 was good for being able to understand how files were organized into the various projects of a solution, but it didn't do much more than that. With Visual Studio 2013, Microsoft has revisited Solution Explorer and given it an overhaul. It still contains all of the functionalities you know from the old Solution Explorer, and it adds to that a range of new features intended to make navigating and searching within your solution a more powerful yet simpler experience.

Getting ready

Open the same VS2010_Web solution that we have been using for the other recipes in this chapter or choose a solution of your own.

How to do it...

  1. We'll begin by navigating through our solution. Locate the Default.aspx page in the VS2010_Web project and click on the arrow next to it so that its contents are displayed. As you would expect, there is a code-behind file and a designer file:

  2. Look at the Default.aspx.cs file. You can see that there is a small arrow next to it just as there was for the Default.aspx page. Click on the arrow:

  3. Visual Studio 2013 expands the file to show its contents, and in the case of a code-behind file, these contents are the class definitions it contains. Classes have methods and properties in them, so click on the arrow next to the _Default class to see the methods inside it. Since the VS2010_Web project is just a shell, there is only an empty Page_Load() method, as shown in the following screenshot:

  4. Now select the IService1.cs file from the VS2010_Web.Services project and expand it to see its contents. You will see that there is both an interface definition in this file (IService1) and a class definition (CompositeType), as shown in the following screenshot:

  5. Right-click on the IService1 interface and click on the Derived Types option to see what classes implement this interface:

  6. The Solution Explorer window will change views to show you the types that either implement this interface or inherit from it, as shown in the following screenshot. Click on the back button (showing the blue background) to return to the standard Solution Explorer view:

  7. Right-click on the IService1 interface and choose the Is Used By option to see where the interface is currently being used. As with the Derived Types option, you will see Solution Explorer change its context to only show the interface and where that interface is used in the solution, including line and column numbers:

  8. Return to the regular Solution Explorer view by clicking on the home button, shown in the following screenshot:

  9. At this point, you know how to navigate using Solution Explorer, and you have already used the existing Navigate To feature in the Finding Visual Studio commands recipe while opening a file. With the enhancements to Solution Explorer, you can locate files in much the same way as with the Navigate To command, albeit with a slightly different user experience. Click on the Search Solution Explorer textbox at the top of the Solution Explorer window, or use the default shortcut key of Ctrl + ; (Ctrl + semicolon).

  10. Enter serv in the textbox and wait a moment for the search results to display. The results should look similar to the following screenshot. You can not only see the filenames that match the search term but also any matching references, classes, and methods:

How it works...

The Navigate To feature from Visual Studio 2010 was a fantastic addition to Visual Studio. It had problems in large projects with many search matches as the location of a match was embedded in the result itself, making it hard to locate the specific match you were after. The new Solution Explorer search tool provides similar results to the Navigate To feature, but having the location of a match represented in the tree view makes it very easy to quickly identify the specific match you are interested in.

There's more...

It's worth mentioning a few other things about searching within your solution.

Navigation behavior

Assuming you have the Preview Tab enabled for Solution Explorer, as you navigate using Solution Explorer to various classes and methods, you may have noticed that the document preview tab was updating and showing exactly where the selected class, method, or property was declared. This makes it easy to see what the code is doing without the need to specifically open the file or scroll through a source file to see what code is actually inside a method, class, or property.

CSS, HTML, and JavaScript files

Even though it's possible to extract the structure from CSS, HTML, and JavaScript files, Solution Explorer doesn't show the internal structure of these files. You can navigate to the source file, but not to any of its contents.

Left arrow icon Right arrow icon
Download code icon Download Code
Estimated delivery fee Deliver to Slovakia

Premium delivery 7 - 10 business days

€25.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Mar 17, 2014
Length: 332 pages
Edition :
Language : English
ISBN-13 : 9781782171966
Vendor :
Microsoft
Category :
Languages :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Estimated delivery fee Deliver to Slovakia

Premium delivery 7 - 10 business days

€25.95
(Includes tracking information)

Product Details

Publication date : Mar 17, 2014
Length: 332 pages
Edition :
Language : English
ISBN-13 : 9781782171966
Vendor :
Microsoft
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 83.98
Visual Studio 2013 Cookbook
€37.99
Visual Studio 2013 and .NET 4.5 Expert Cookbook
€45.99
Total 83.98 Stars icon

Table of Contents

9 Chapters
Discovering Visual Studio 2013 Chevron down icon Chevron up icon
Getting Started with Windows Store Applications Chevron down icon Chevron up icon
Web Development – ASP.NET, HTML5, CSS, and JavaScript Chevron down icon Chevron up icon
.NET Framework 4.5.1 Development Chevron down icon Chevron up icon
Debugging Your .NET Application Chevron down icon Chevron up icon
Asynchrony in .NET Chevron down icon Chevron up icon
Unwrapping C++ Development Chevron down icon Chevron up icon
Working with Team Foundation Server 2013 Chevron down icon Chevron up icon
Languages Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2
(13 Ratings)
5 star 53.8%
4 star 23.1%
3 star 15.4%
2 star 0%
1 star 7.7%
Filter icon Filter
Top Reviews

Filter reviews by




A. Zubarev Apr 18, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Oh Visual Studio! A very fast evolving product, who does not use it when developing on a Microsoft platform?I used the one 1st in my life that came in late 90s, it if I remember correctly it offered 3-4 projects.Today, after it went through such an evolution Visual Studio has reached an enormous heights. From ETL to reports, from DirectX to tests, from database projects to Windows Store App development, and what not?A book on Visual Studio makes a lot of sense.Gladly Packt has one off its sleeve that is called Cookbook, in my view these books simply avoid wasting your time. Yet this book is quite universal, if you wish, it will take you through basics as opening a developers` account, or if you do not want to walk baby steps you can jump straight to very advanced topics as say the TPL Dataflow, WPF, Bootstrap and more.I felt the book can be sliced and diced like a multidimensional cube, back and forth without any particular order and all would still make sense. Feel free to pick only the parts you need or like.I enjoyed reading on Python with .Net integration, turned out it is simple.WCF is something I will be doing soon at work, so this book will be revisited gain.The book is full of graphics, coloreful, high quality graphics, very well structured examples, and full of insight, discusses improvements and suggest on best practices.The book also covers working with a workflow, graphics, it was even fun to refresh my C++ skills in Visual Studio 2013 retrospective.In terms of closing, it makes sense to have a printed copy or two, the book must be kept on a bookshelf ready to be borrowed by colleagues. Having it in the eBook format is as helpful as you can search it whenever you need some reference or a refresh. On another note, I wish the book could cover more material as BI, Database, F# development,I am giving this book the maximum mark possible.
Amazon Verified review Amazon
CaroleCronan Jul 09, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent
Amazon Verified review Amazon
Rae J. Owen Apr 03, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great book very helpful.
Amazon Verified review Amazon
Sergio Costa May 25, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
There’s a lot on this book, not just for those who already know and use Visual Studio and want to learn what’s new with the 2013 version, but also for those that never used it before or are even new to .Net programming. If you are a new .Net programmer, I don’t recommend you get as your first programming book, of course, but I do recommend you get it sometime along your way through your .Net path as a developer. If you are a seasoned developer, you will find a lot of stuff you probably already know but you’ll also certainly be surprised with some nice tips and get to learn a lot of new features shipped with VS2013.I definitely recommend you check Visual Studio 2013 Cookbook whenever you can. If you're serious about developing with Visual Studio, this is a great book to get and you'll certainly find something new to learn.
Amazon Verified review Amazon
Matthew Rowan Apr 28, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Why would you buy a Visual Studio 2013 book instead of just using the Internet to find what you need? Simple, time and content. The amount of new features and ways to do things in this version is substantial. Mining the Internet you are sure to miss many gems that could make a large difference to your day-to-day work. Going through this book you will benefit that a team of people has done the work for you. Ensuring they have included everything and the content is correct for your easy perusal.Chapter 1 gives a very good overview of the new additions to the main tool you use each day.Chapter 2 gives a very good starting place for Windows 8.1 development. It will get you past the new stuff quickly to allow you to get into the code.Chapter 3 goes over Web Development with MVC 5 and the new One ASP.NET model.Chapter 4 uses some I'm not dead yet WPF ("WPF remains the recommended choice for developing desktop applications on the Windows platform. Visual Studio 2013 itself is a WPF application", p 118) WF, WCF and .NET application development.Chapter 5 Debugging EnhancementsChapter 6 Asynchrony in .NETChapter 7 C++, I skimmed this one, but the C++ developer should be thrilled, and it makes me want to learn DirectX.Chapter 8 Team Foundation Server features from a users perspective. Great features that many developers aren't utilizing that can very much help day-to-day. If you are managing a TFS server though, you'll want more than what is provided here.Chapter 9 is on languages TypeScript, Python and IronPython. TypeScript I knew and understand, but I have no idea about Python, and don't really want to, but it's good to know it's available if that's your flavour of choice.Appendix contains recipes on Installers, Submitting Windows Store apps, Visual Studio Add-ins and extensions, and creating your own snippets.The "There's more..." sections littered throughout are valuable on there own, revealing many power user features I was unaware of. The recipe format of the books make it a great reference to have on-hand. Going to the relevant recipe within the book will be a faster and more reliable process than going online.I intended to flick through this book quickly and dive in on a couple of chapters. I however could not help but go through it all. The capabilities we have available to us, just from Visual Studio is amazing. Going over it all I can't help but think of all the possibilities and opportunities. Now I must get back to coding.Review also posted on my blog [...]Disclaimer: I was provided a complimentary electronic copy of this book by the publisher. In no way was I directed on the content of my review. Opinions are mine alone.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela