Visual Studio 2010 Tips and Tricks

If you’re a.NET developer like me, you live 75% of your work life on your computer, inside IDE Visual Studio, bug tracker or source control system (TFS, SVN, CVS). Coding is a lot easier when you know how to use your tools like Visual Studio 2010 more effectively. To optimize experience with this IDE, here these tips and shortcuts: Intellisense, Code Editor, Navigation, Debugging, Search Shortcuts...

Search Shortcuts
Beyond Navigate To and Call Hierarchy, Visual Studio 2010 doesn't include new search features, but existing features are wildly underutilized. Beyond a simple search, you can Find in Files, Find Symbols, use F3 and Ctl-F3 for the next and previous, and use the quick find box in the toolbar. Find in Files lets you specify the directory to search and the file types. Find Symbols lets you limit your search by platform and create custom component sets for searching as well as supporting both prefix and substring searches. And you can use RegEx in many search dialogs. For example how to create visual studio 2010 project from existing code folders?

There are two additional keyboard search tricks. If you select a set of characters in your code and hit Ctl-F3 or Ctl-Shift-F3, you'll navigate forward and back through any matches. If you press Ctrl-I or Alt-I -- depending on your keyboard layout -- you'll enter incremental search mode, and the cursor will change to an arrow and binoculars. In this mode, Visual Studio will refine your search as you type, moving to the next matching value. You can also hit F3 or Shift-F3 to navigate to the next or previous matches. Hitting these keys also ends incremental search mode and places your search text into the quick search box for easy reference or reuse.

Upgrade Tips
Now for the caveats: If you move existing projects to Visual Studio 2010 from Visual Studio 2008 or 2005, your platform target is not updated. Visual Studio 2010 supports development targeting older framework libraries to aid in application deployment, but the project itself is altered to become a Visual Studio 2010 project and you won't be able to open it in Visual Studio 2008. On the surface, the changes are just version number variations in the project and solution files. Beneath the surface, there's no guarantee that the structure of supporting data remains unchanged, so consider the move to Visual Studio 2010 a permanent one for your project, and keep backups in case you have a reason to revert. Changes to the workflow of data projects managed from Visual Studio (such as how you load scripts) are significant and may be confusing if you manage databases from Visual Studio.

Visual Studio 2010 is a full rewrite. While it's effectively a 1.0 product, overall performance and stability are adequate. But you're much more likely to experience quirky behavior (such as the Clipboard ring sometimes not working as expected) and occasional crashes than in Visual Studio 2008.

Get Microsoft Silverlight


camelCase / Substring Filters Suggestion mode [CTRL]+[ALT]+[SPACE] Undeclared types after “new” ( C# Only )

IntelliTrace is a feature previously known as Historical debugging, which is a major enhancement made to the Visual Studio 2010 debugger. When an exception occurs, you usually start debugging with breakpoints set in suspected areas and check variable/object values for correctness.

But if an exception occurs when IntelliTrace is enabled, it allows you to just go back in a time of your application execution and find out what events got raised and what were the values of various variables, etc. similar to Call stack like approach. This helps you inspect all the events that finally triggered the exception. This helps in many ways; even you don’t need to worry about breakpoints.

Code Editor Tricks  Dev315-EditorTricks.wmv (12.50 MB)

  • Call Hierarchy ( C# Only )
  • Find all references [SHIFT]+[F12]
  • Metadata as Source ( C# Only )
  • Code Definition Window ( C# Only )
  • Highlight references and keywords
  • Navigating Highlights [CTRL]+[SHIFT]+[UP|DOWN]
  • Multi-Line Edit – Box Select
  • ZOOM Mouse and Keyboard [CTRL]+[SHIFT]+[<|>]


Outlining Dev315-Outlining.wmv (6.19 MB)

  • Ad-Hoc Regions
  • Hide [CTRL]+[M],[H]
  • Show [CTRL]+[M],[U]
  • Collapse to definition
  • Outlining preview on margin hover
  • Double click margin to Expand/Collapse


Navigation Dev315-Navigation.wmv (13.62 MB)

  • Go to Definition [F12]
  • Go to Definition Stack ( C# Only ) [CTRL]+[SHIFT]+[7|8]
  • Iterate List Window (IE. Find Results) [F8]
  • Navigate To [CTRL]+[,]
  • Navigate to open file selection [CTRL]+[ALT]+[DOWN]Next | Previous Method ( VB Only) [CTRL]+[UP|DOWN]

You can use Navigate To(Ctrl +,) to search specific methods, class’, etc. in your code. This helps to navigate your code faster, code navigation speed in Visual Studio 2010 is increased highly because of this new feature. This also comes handy when you keep jumping between different methods of your code frequently. In previous versions of Visual Studio, you didn’t have such a swift option.

Pin, Unpin(delete), add comment

Also, we can click the pin icon next to a variable’s DataTip, and it will stick to your code window for you to drag & place as you like. Remove it by clicking the "X" in the DataTip mouse hover menu. Add comments and notes for a variable by clicking the double down arrow in the DataTip hover menu.

We can do more beautiful things using Navigate To, like, you can type the abbreviation of the method to find it, as below or type the words like “get categories,” “search category.”

Debugging KB Shortcuts

  • F5 Run (Stop on First/Next breakpoint)
  • F9 Set|Delete a breakpoint
  • CTRL+F9 Disable (not Delete)
  • CTRL+SHIFT+F9 – Remove all Breakpoints
  • F10 Step Over
  • CTRL+F10 – Run to Cursor
  • Even if Debugger isn’t started
  • F11 – Step Into
  • SHIFT F11 – Step Back

We know that, in debugging mode, we can hover our mouse over a variables, objects and inspect, edit and explore it and we call this as DataTip. VS 2010, we can stick DataTips to our code window and drag and drop to any place, and the DataTip will hang there. This new feature gives pretty easy view to monitor the variables for your current debugging.

Run to Cursor (Ctrl + F10)

Often I see people debugging applications by hitting a breakpoint early in their implementation and then repeatedly using F10/F11 to step through their code until they reach the actual location they want to investigate.  In some cases they are carefully observing each statement they step over along the way (in which case using F10/F11 makes sense).  Often, though, people are just trying to quickly advance to the line of code they care about – in which case using F10/F11 isn’t the best way to do this.

Instead, you might want to take advantage of the “run to cursor” feature that the debugger supports.  Just position your cursor on the line in your code that you want to execute the application to, and then press the Ctrl + F10 keys together.  This will run the application to that line location and then break into the debugger – saving you from having to make multiple F10/F11 keystrokes to get there.  This works even if the line of code you want to run to is in a separate method or class from the one you are currently debugging.

Get Microsoft Silverlight

Extension Manager for downloading and installing plugins

The Extension Manager in Visual Studio 2010 will allow you to download and install cool plug-ins for your VS IDE. You can bring up the extension manager window by clicking Tools->Extension Manager. Extension Manager will connect to Visual Studio 2010 online Extension library, and you can search and find cool plug-ins there.

Once installed, you may also Disable or Uninstall your plug-ins from the extensions manager.

Architecture Explorer (Ultimate only)

A cool addition in VS2010 is the Architecture Explorer (Click View->Architecture Explorer). The Architecture Explorer will provide you a very friendly interface to browse through and navigate to your solution assets. You can right click on an item (Namespace, Class Name, or Class Member, etc.) and select ‘View Content’ to navigate to the definition as well.

Also, you can export the selected items to a graph document from the Architecture Explorer. You can do this by selecting the members, and click the ‘Create new graph document’ button (in top left corner) of the Architecture Explorer. Let me export some of the members in my OrderViewModel class, and have a look at the generated graph. You can also use the graph document to understand your code members in a better way, to analyze circular references, un referenced nodes, etc. (see the image below.)

Generating Sequence Diagrams To Inspect And Document control flow

Another cool feature in Visual Studio 2010 is the ability to generate Sequence Diagrams. You may right click inside a method and select “Generate the sequence diagram”  from the pop-up menu, to generate the diagram. In this example, you may see that my SubmitOrder method in OrderViewModel class is instantiating an OrderServiceClient, to call AddOrderAsync method inside the same.

And here is the bonus by Sandra from Microsoft, happy coding:
Get  Microsoft Silverlight

Tip #1 How to not accidentally copy a blank line TO – Text Editor – All Lang – Gen – Apply cut or copy commands to blank lines
Tip #2 How to cycle through the Clipboard ring  Ctrl+Shift+V (Edit.CycleClipboardRing)
Tip #3 How to use the Undo stack  Undo button on Standard Toolbar
Tip #4 New! Automatic highlighting of symbols Hover over symbol, then Ctrl+Shift+Arrow to navigate
Tip #5 How to navigate forward and backward w go-back markers View.NavigateBackward (Ctrl+Minus), View.NavigateForward (Ctrl+Shift+Minus)
Tip #6 New! How to collapse a region with ease Hover over any part of region and click. Or Ctrl+M, Ctrl+M
Tip #7 How to reach the navigation bar via keyboard shortcut Ctrl+F2 (Window.MoveToNavigationBar), type-ahead selection
Tip #8 How to use Navigate To Ctrl+comma
Tip #9 How to split a window and create new one's Window – Split, Window – New Window
Tip #10 How to show line numbers in the editor Tools – Options – Text Editor – All Languages – General  - Line Numbers
Tip #11 How to enable virtual space TO – Text Editor – All Languages – General
Tip #12 How to view visible white space Edit – Advanced – View White Space
Tip #13 How to change the color of visual white space glyphs TO – Env – Fonts and Colors – Text Editor – Visual White Space
Tip #14 How to increase the editor’s ToolTip font size TO– Env – Fonts and Colors –Show Settings for – Editor ToolTip
Tip #15 New! How to zoom in/out in Editor Ctrl+Mouse Wheel / Edit in zoom control
Tip #16 How to change text editor font size via Keyboard Macros.Samples.Accessibility.<increase/decrease>TextEditorFontSize
Tip #17 Diff Automatic vs. Default in Fonts and Colors
Tip #18 How to print boldly TO – Env– Fonts and Colors - Show Settings for – Printer
Tip #19 How to use box/column selection in the editor Shift+Alt+Arrow, or Mouse+Alt
Tip #20 New! How to use Multiline Edit Shift+Alt+Arrow, type
Tip #21 How to format the current document Ctrl+K, Ctrl+D – (Edit.FormatDocument)
Tip #22 You can remove unused using statements in C# Context Menu – Organize Usings – Remove Unused Usings
Tip #23 How to remove a project from Start Page Right-click project, select Remove from list
Tip #24 How to set bookmarks and navigate among them Edit.ToggleBookmark (Ctrl+K, Ctrl+K )
Tip #25 You can bookmark your quick find results Ctrl+F, then press bookmark all
Tip #26 How to increase Intellisense font sizes TO – Env – Fonts and Colors - Show Settings For - <item>
Tip #27 How to increase Environment font TO – Env – Fonts and Colors - Show Settings For – Environment Font
Tip #28 Toggle Statement Completion tabs via keyboard All tab: Alt+.  and  Common Tab: Alt+,
Tip #29 New! How to do Pascal / Sub-string matching in Intellisense
Tip #30 New! How to enable Suggestion mode in Intellisense Ctrl+Alt+Space to enable
Tip #31 You can insert a snippet by pressing Tab Tab Type in snippet shortcut word, then hit Tab Tab to insert
Tip #32 New! How to browse new code snippets and add new one's Tools – Code Snippet Manager, HTML, and Javascript
Tip #33 How to insert a code snippet around a block of code in C# Select code, then Ctrl+K, Ctrl+S.  Command: Edit.SurroundWith
Tip #34 How to behold the power of incremental search  Ctrl+I  - (Edit.IncrementalSearch)
Tip #35 Use Ctrl+F3 to search for currently selected word Edit.FindNextStatement
Tip #36 How not to search for the currently-selected word Tools – Options – Environment – Find and Replace
Tip #37 You can use F3 to search for the last thing you searched for Edit.FindNext
Tip #38 You can customize what files to find in Find in Files – Look in – Choose Search Folders
Tip #39 You can use a reg key for customizing search results HKCU\... \10.0\Find, String Find results format = $f$e($l,$c):$t\r\n
Tip #40 Use Ctrl+Alt+Down to drop down the file tab channel Window.ShowEzMDIFileList
Tip #41 Use Close All But This on files in the file tab channel File.CloseAllButThis
Tip #42 You can copy a file’s full path for the file tab channel File.CopyFullPath
Tip #43 Open a Windows Explorer browser to the active file File.OpenContainingFolder
Tip #44 How to close just the selected files you want Window – Windows
Tip #45 How to use the IDE Navigator Hold Ctrl key, then press tab (or shift+tab)
Tip #46 How to navigate all open tool windows  Hold Alt key, then press F7 (or Shift+F7)
Tip #47 How to disable the IDE Navigator Rebind Window.Previous/NextDocumentWindow
Tip #48 How to disable statement completion TO – Text Editor – All Language – Auto List Members
Tip #49 How to customize what the tool window push pin does TO – Environment – General
Tip #50 Show autohiding tool windows via autohide channel Right-click in the autohide channel to view context menu
Tip #51 How to rock a tool window via keyboard Ctrl+Double Click Tool Window title bar
Tip #52 You can maximize a tool window in the editor Window – Tabbed Document
Tip #53 New! How to move a file onto a secondary monitor Click-Drag a file out of File Tab Channel
Tip #54 New! How to snap file windows to monitor edges Windows 7 feature: Win key+Arrow
Tip #55 New! How to put file back into File Tab Channel  Ctrl-DoubleClick
Tip #56 New! How to reverse the order the file tabs open TO – Doc – insert docs to right of existing ones
Tip #57 Customize the tool window ‘x’ button  Tools – Options – Environment – General
Tip #58 How to access a toolbar within a tool window Shift+Alt (note: Alt+Shift will not work)
Tip #59 How to quickly access full-screen mode Shift+Alt+Enter – (View.FullScreen)
Tip #60 How to enter the File window layout mode Open a file from a command prompt
Tip #61 How to use the keyboard to jump to output window panes  Window.NextSubPane. Need to create shortcut
Tip #62 Drag and drop code onto the Toolbox’s General tab Either drag and drop code, or use Cut/Copy shortcuts
Tip #63 How to use Ctrl+Arrow to move among the Toolbox Tabs
Tip #64 Switch between the Icon View and the List view in Toolbox On Context Menu, uncheck List view
Tip #65 You can use Show All to find your hiding Toolbox controls On Context Menu, check Show All
Tip #66 You can show custom tokens in the Task list TO – Environment – Task List, add custom token to list
Tip #67 How to find what development settings you last reset to HKCU\Software\Microsoft\VisualStudio\10.0\Profile, LastResetSettingsFile
Tip #68 You can create a macro for your import/export settings
Tip #69 How to open a file without any UI Tools.GoToCommandLine
Tip #70 How to have fun with the Find Combo Box Does everything from finding stuff to making coffee
Tip #71 How to not show the Start Page on launch TO – Env – Startup – anything but Show Start Page
Tip #72 How to open to the last loaded project TO – Env – Startup – Load Last Loaded project
Tip #73 How to use solution folders to hide projects Solution Explorer context menu – Add New Solution Folder
Tip #74 How to create temp or throw away projects TO – Projects and Solutions – uncheck Save new projects when created
Tip #75 How to hide or show the Project Location is Not Trusted message box TO – Projects and Solutions
Tip #76 How to show the Misc Files project in Solution Explorer TO – Env – Documents, show Misc project
Tip #77 How to type-ahead selection in solution explorer Just type name of file and focus will jump to file that matches
Tip #78 How to add a solution to a solution File – Open Project, choose a solution (not a project) file
Tip #79 How to have the Sln Explorer show active file TO – Projects and Solutions – General – Track Active Item
Tip #80 How to use tracepoints to log stuff in your code Editor context menu – Breakpoints – Add Tracepoints
Tip #81 How to use DataTips to edit a variable’s content Click inside DataTip contents to edit
Tip #82 New! How to leave comments in Data Tips Expand down arrow and type in comment
Tip #83 New! How to Export Data Tips Debug – Export DataTips
Tip #84 New! How to label breakpoints Right-click on breakpoint in Bp Window, Edit Labels
Tip #85 New! How to export breakpoints Breakpoint Window – Export Breakpoints button on toolbar
Tip #86 How to select the startup project from the Sln Explorer Tools – Options – Projects and Solutions – Build and Run
Tip #87 How to make statement completion transparent Hold down Ctrl key.
Tip #88 You can use Ctrl+. To show a smart tag
Tip #89 Shortcut to go directly to the class view search bar View.ClassViewGoToSearchCombo
Tip #90 How to bring up Code Definition Window in C# View – Code Definition Window, Ctrl+\, D
Tip #91 How to bring up the Call Hierarchy dialog View – Call Hierarchy, Ctrl+Alt+K
Tip #92 How to use “Devenv /splash” to speed up launch, maybe
Tip #93 You can create project/item templates File – Export Template
Tip #94 New Project from Existing Code File – New – Project from existing code
Tip #95 Edit project file within IDE Unload then select Edit
Tip #96 XAML Visualizer Drop down arrow in DataTip to show XAML Visualizer option
Tip #97 How to see the caught exception in Watch Window Add $exception to watch window
Tip #98 You can disable the Exception Assistant Tools – Options – Debugging – General
Tip #99 New! How to use Historical debugging aka Intellitrace Up / Down arrows in gutter like DVR controls
Tip #100 New! How to open IntelliTrace log Double-click .iTrace files to open in VS
Tip #101  New! How to use Extension Manager  Install VS Tips extension to get Tips in Start Page

Word document with the short description of 101 tips 101 VS 2010 tips.Docs (23.63 kb)


Microsoft Visual Studio Tips

Twitter of Visual Studio tips and tricks

Visual Studio Tricks

What are your tips and tricks in Visual Studio IDE 2010? Do you understand how to create visual studio 2010 project from existing code folders?

Comments (2) -

  • What do you thinks about this tips, what else do you know?
  • Sorry man, but you in ban list. We discussing here Visual Studio 2010 Tips and Tricks, but not your staff...

Pingbacks and trackbacks (1)+

Comments are closed