TechEd Australia and New Zealand – 25 Visual Studio 2008 IDE Tips

Thanks for coming to today’s session! As I’ve said (or about to say), don’t take notes! Here are all the tips for you. Just sit back, relax, and enjoy the show!

0. Know your Keybindings! All these are in the General Development Settings.

Searching

1. How to behold the power of incremental search

http://blogs.msdn.com/saraford/archive/2007/07/23/did-you-know-behold-the-power-of-incremental-search.aspx

Command: Edit.IncrementalSearch

Shortcut: Ctrl+i

2. Ctrl+F3 to search for currently-selected word

http://blogs.msdn.com/saraford/archive/2007/10/26/did-you-know-ctrl-f3-searches-for-the-currently-selected-string-without-brining-up-the-find-window.aspx

Command: Edit.FindNextStatement

3. F3 to search for last thing you searched for

http://blogs.msdn.com/saraford/archive/2007/10/25/did-you-know-f3-searches-for-the-last-thing-you-searched-for.aspx

Command: Edit.FindNext

4. Customize what files to find in

http://blogs.msdn.com/saraford/archive/2007/11/07/did-you-know-how-to-customize-what-files-to-find-in.aspx

Find In Files – Look in – Choose Search Folders

5. You can use a reg hack for customizing search results

http://blogs.msdn.com/saraford/archive/2008/11/24/did-you-know-you-can-customize-how-search-results-are-displayed-in-the-find-results-window-363.aspx

HKCU\Software\Microsoft\VisualStudio\9.0\Find String Find=$f$e($l,$c):$t\r\n

Editing

6. How not to accidentally copy a blank line

http://blogs.msdn.com/saraford/archive/2007/09/28/did-you-know-how-not-to-accidentally-copy-a-blank-line.aspx

Tools – Options – Text Editor – All Languages – General, Uncheck Apply cut or copy to blank lines

7. How to cycle through the Clipboard ring

http://blogs.msdn.com/saraford/archive/2007/10/01/did-you-know-how-to-cycle-through-the-clipboard-ring-to-paste-different-things.aspx

Command: Edit.CycleClipboardRing

Shortcut: Ctrl+Shift+v

8. How to use box/column selection in the editor

http://blogs.msdn.com/saraford/archive/2007/07/27/did-you-know-how-to-do-box-selection-in-the-editor.aspx

Command: Edit.LineUpColumnExtend, Edit.LineDownColumnExtend, Edit.CharRightColumnExtend, Edit.CharLeftColumnExtend

Shortcut: Shift+Alt+Arrow

9. You can copy a file’s full path / open windows explorer from the file tab channel

http://blogs.msdn.com/saraford/archive/2008/01/09/did-you-know-you-can-copy-a-file-s-full-path-from-the-file-tab-channel.aspx

Command: File.CopyFullPath

10. Drag and drop code onto the toolbox’s general tab

http://blogs.msdn.com/saraford/archive/2008/04/10/did-you-know-you-can-drag-and-drop-code-onto-the-toolbox-general-tab-191.aspx

11. You can use Ctrl+. to show a smart tag

http://blogs.msdn.com/saraford/archive/2008/11/18/did-you-know-ctrl-shows-a-smart-tag-359.aspx

Command: View.ShowSmartTag

12. You can insert a snippet by pressing Tab Tab

http://blogs.msdn.com/saraford/archive/2008/06/10/did-you-know-you-can-insert-a-snippet-via-tab-tab-234.aspx

Type in snippet shortcut, then press Tab Tab

Customizing

13. You can create temp or throw away projects

http://blogs.msdn.com/saraford/archive/2008/02/25/did-you-know-you-can-create-temp-or-throw-away-projects-158.aspx

Tools – Options – Projects and Solutions – General, uncheck Save new projects when created

14. Change text editor font size via keyboard (Accessibility macros)

http://blogs.msdn.com/saraford/archive/2008/06/20/did-you-know-you-can-bind-macros-to-keyboard-shortcuts-or-how-to-quickly-increase-decrease-your-text-editor-font-size-242.aspx

Command: Macros.Samples.Accessibility.DecreaseTextEditorFontSize

Command: Macros.Samples.Accessibility.IncreaseTextEditorFontSize

15. How to open a file without any UI

http://blogs.msdn.com/saraford/archive/2007/11/26/did-you-know-how-to-have-fun-with-the-find-combo-box.aspx

Ctrl+/ (or whatever Tools.GoToCommandLine is bound to)

alias fo file.openfile

fo <filename>

16. Guidelines in the editor registry key hack

http://blogs.msdn.com/saraford/archive/2008/04/01/did-you-know-you-can-display-guidelines-in-the-editor-and-tip-of-the-day-ends-today-184.aspx

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Text Editor  String RBG(128,0,0) 5, 20

17. You can create a macro for your import/export settings – see http://blog.jeffhandley.com/archive/2009/03/31/vs-profiles.aspx

http://blogs.msdn.com/saraford/archive/2008/12/05/did-you-know-you-can-create-toolbar-buttons-to-quickly-toggle-your-favorite-vs-settings-371.aspx

18. How to not show the start page (or have the last loaded solution open)

http://blogs.msdn.com/saraford/archive/2008/01/03/did-you-know-how-to-customize-what-visual-studio-opens-to-or-how-to-make-the-start-page-not-show-up-when-vs-opens.aspx

Tools – Options – Environment – Startup, At Startup

19. File tab channel registry hack

http://blogs.msdn.com/saraford/archive/2008/10/09/did-you-know-you-can-keep-recently-used-files-from-falling-off-the-file-tab-channel-331.aspx

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0 key, you can create a DWORD UseMRUDocOrdering = 1

20. How to show Misc Files Project to keep your files around

http://blogs.msdn.com/saraford/archive/2008/01/01/did-you-know-how-to-show-the-miscellaneous-files-project-in-the-solution-explorer.aspx

tools – options – environment – documents, show miscellaneous files in Solution Explorer

21. Edit project file from within IDE (unload project)
http://blogs.msdn.com/saraford/archive/2008/10/10/did-you-know-how-to-edit-a-csproj-or-vbproj-project-file-within-the-ide-332.aspx

Unload project, edit project, reload project

Debugging

22. You can use tracepoints to log stuff in your code

http://blogs.msdn.com/saraford/archive/2008/06/13/did-you-know-you-can-use-tracepoints-to-log-printf-or-console-writeline-info-without-editing-your-code-237.aspx

Right-click in indicator margin, select breakpoints, select Insert Tracepoint

23. How to get the find source dialog back

http://blogs.msdn.com/saraford/archive/2008/09/17/did-you-know-how-to-get-the-find-source-dialog-back-instead-of-the-there-is-no-source-code-available-message-315.aspx

Solution Properties, under Common Properties – Debug Source Files, Delete Do no look for these source files edit box contents

24. You can disable the exception assistant

http://blogs.msdn.com/saraford/archive/2008/08/05/did-you-know-you-can-disable-the-exception-assistant-274.aspx

Tools – Options – Debugging – General, uncheck Enable the Exception Assistant

25. You can use the XML Visualizer

http://blogs.msdn.com/saraford/archive/2008/09/25/did-you-know-you-can-use-the-xml-visualizer-to-view-xml-321.aspx

Drop down the little down arrow on the data tip or in the watch window.

How to trick Visual Studio to not show line numbers for blank lines?

Going through my folder of my blog “contact me” emails, I came across this question. I like tricking Visual Studio into doing things, so I thought I’d share.

Is there a way to display only line number of coded lines, i.e. don’t number blank lines? Numbered blank lines makes showing code in powerpoint decks hard to follow.

Here’s the screenshot of what could go into your powerpoint deck.

line numbers only on real lines of code

To do this,

  1. Enable Word Wrap (Tools Options – Text Editor – All Languages – General)
  2. At the end of the first real line (like #28 above), start inserting white space until it goes off the screen. Note the Word Wrap glyph.
  3. Turn off the Word Wrap glyph (same place as in step 1) and Turn off “View White Space” (Edit – Advance – View White Space)

Here’s what the hack really looks like

what hack looks like using visible white space

Sorry, this isn’t the start of a new VS tip series. Just wanted to share some q&a that have come in through my blog.

Technorati Tags: VS2005Tips,VS2008Tips

Did you know that today’s tip on msinfo32.exe ends the series? -#382

Cause nothing lasts forever… even cold November rain

My most sincere thanks to you for reading the 17 month series. Because of you, people from my hometown are going to college. All because of community inspiring community.

I want to part ways saying community is about people, and don’t let anyone tell you otherwise. It is not the “if you build it they will come” infrastructure theory (that’s just a movie). Community is about the connections we establish and foster. Or better stated by someone whose name I cannot recall, Community is about being excellent to each other.

I *really* wish I could continue, but I haven’t worked on VS in 3 years now. And 80% of the series was written in my personal time. I would tell people I refuse to calculate just how much time I’ve spent writing tips. But now that it’s over, the answer is 12,500 minutes or 208 hours. And no, this doesn’t count the hours writing the book, which I refuse to ever do.

My next quest is to do something with the CodePlex community (my actual day job) like I did here with Visual Studio or Accessibility or the Legal Evangelism Thinkweek paper. yes, i know, i know, “legal what??”

I’ve been waiting a very long time to run some experiments in connecting with the CodePlex community, and finally I can start to play in this space. If you have any ideas for engaging the CodePlex / Open Source community that you think I should try, you know where to find me. Never underestimate the power of community inspiring community.

And now, here’s your final Tip of the Day for Visual Studio 2008, already in progress…

msinfo32.exe

I can never remember the executable name (msinfo32) to start the System Information application.

System Information application

Fortunately, I can always rely on the Visual Studio Help About dialog to launch the app for me. Go to Help-About, and on the bottom right corner of the page, you’ll see the System Information button.

Visual Studio Help About window

Clicking System Info will do the same as running msinfo32.exe from the command prompt.

Happy Visual Studio’ing!!!

But don’t unsubscribe yet! Starting in 2009, I plan to create a separate feed somewhere (just not on this blog) to restart the series all over again, but 7 days a week. Stay tuned.

Technorati Tags: VS2005Tip,VS2008Tip

View original comments

Did you know… How to optimize Visual Studio for multi-monitors? – #381

This is really a repost from 3 (and even 4) years ago when Tip of the Day was just a weekly series. I’m really glad to hear that Visual Studio 2010 will have multi-monitor support. Really, really glad, as you can tell from the original blog post. Of course, there’s a story behind this which should be told at another time…

Here are some ideas for optimizing Visual Studio (non-2010 versions). Ironically, I don’t use multi-monitors anymore (neck strain) so hopefully I haven’t forgotten to find someone’s machine to take some screenshots.

  1. Stretching the VS across dual monitors

    Put Visual Studio into a restore state, where you can resize it. Then stretch VS across both monitors.

    One of the benefits of doing this is to be able to view code in each monitor.  You can do a vertical split (Window – New Vertical Tab Group) down the center of the dual monitors.  Now you can have code windows on each monitor.

    You can also customize the toolbars to place them on which ever monitor you prefer as your primary.  Just grab the grip control for the toolbars and drag them over to whichever monitor.

  2. Viewing Debugging Tool Windows on secondary monitor

    Whenever I’m debugging, I prefer to have tool windows like the Watch Window and Output Window on the secondary monitor, with VS occupying the primary monitor.  These tool windows have to be either dockable or floating (floating is what you probably want).  Resize these windows to occupy half of the screen.  Remember, you can use Tools – Import / Export Settings to save your favorite window layouts.  And since these windows only appear during debugging, you don’t have to worry about them occupying your secondary monitor when not in use.

  3. Place External Help on secondary monitor

    Put DExplore (Documentation Explorer) on the second monitor, but most of you probably already do this instinctively.

For more ideas, or to read the original blog post, go to http://blogs.msdn.com/saraford/archive/2005/07/20/441126.aspx

Did you know… There is an Open Source command in Visual Studio? – #380

A while back, when I was collecting Visual Studio tips, the “Open Source” command was pointed out to me. Considering my day job (I’m the Program Manager for CodePlex.com), I couldn’t wrap my head around this command, even after the 2 second demo. After a few minutes, it clicked that it was “open” as in “view,” and not as in “Open.”

In honor of my day job, I decided to showcase this command as a tip. (My blog title made you look, didn’t it?)

the Open Source command

In DExplorer (Documentation Explorer), whenever you do a search, you’ll get results by different search providers.

Open Source command in DExplorer

The above example shows a CodeGuru article result. Selecting open will take you directly to the article, but selecting open source will take you directly to CodeGuru.com. In other words, it will open the source of the article.

Technorati Tags: VS2005Tip,VS2008Tip

Did you know… You can go directly to the installed code samples from within Visual Studio? – #379

This tip is specific for Visual Studio 2008.

You can easily find the samples that have been installed for Visual Studio by going to Help-Samples. Then in the browser, click on the local Samples folder link.

Samples on Disk section of Samples page

As the message box states, the samples are in a .zip file, so you’ll need to extract these files before you attempt to build. Otherwise, the build will fail, and you’ll wonder why the samples that came with the product don’t work.

Technorati Tags: VS2008Tip

Did you know… How to turn on or off Dynamic Help? – #378

I feel obligated to talk about Dynamic Help. In any feature area that I tested, there was always the Help category in the test case bed. The Help category represented things like F1, documentation content, and of course Dynamic Help.

Dynamic Help is a tool window that will always give you a list of related help documents based on your current context.

For example, suppose you’re in an empty C# class with the focus on the keyword class. In dynamic help, you’ll see a list of Help topics including “class (C# Reference)” and “C# Keywords”

Dynamic Help showing class keyword help topics

And jumping to a WinForm Designer on a button causes the context to change

Dynamic Help showing button help

The Dynamic Help tool window is found at Help – Dynamic Help. I think most of the default settings do not show the Dynamic Help window by default.

Also note that if you are using a Screen Reader (or a similar Assistive Technology Device), you should definitely turn off Dynamic Help by closing the window and permanently saving that window layout. The issue is a Screen Reader is always looking for things that are changing on the screen, especially in the active application, at least back in my day. When I first started learning how to use screen readers, I would hear these random words out of nowhere. It took me a while to realize it was coming from the Dynamic Help window changing context and updating its UI. In addition, you’ll experience some performance improvements when the screen reader isn’t trying to figure out what to read and what to ignore.

Technorati Tags: VS2005Tip,VS2008Tip

Did you know… You can narrow search results by turning off partial matches? – #377

If you do a search for the phrase “how to create a custom winform control” using the default options in the General Development Environment, you’ll get back 500 results, as shown below.

search query with 500 results

If you go to Tools – Options – Help – General (and in VS shell, add Environment in the node path), you’ll see the option include partial matches in local search results.

image

If you uncheck this option and repeat the search, you’ll have only 9 hits in local help to scan through instead of 500.

same search query with only 9 results

Technorati Tags: VS2005Tip,VS2008Tip

Did you know… How to tweak your search results? – #376

Today’s tip is just a collection of some tweaks you can make to your search results. Although 16 months ago, I would have said each one of these tweaks is its own tip. But these days I’m all about quality over quantity , since you readers keep me honest when I start to slack. =D

Tip 376.A You can make the abstracts appear as Tooltips

If the abstracts become way to distracting or you want to see more results per page,

showing search results with abstracts

you can Right-click on any search result and uncheck Show Abstract. Now the abstracts only appear in the tooltip.

showing search results with abstracts

Tip 376.B You can remove the highlight search hits by refreshing the site

If you have a lot of terms in your search query, like in the example below “how to define a class in C#” it can be a little hard to read.

lots of highlighted words on a search result page

I couldn’t find any highlight command that could toggle the highlight state, so the best I can offer is hitting the refresh button. It removes the highlight for both local and online search.

Web Browser refresh button

If hitting refresh gets old, you can go to Tools – Options – Help – General (in DExplorer, if in VS add the Environment node), and uncheck Highlight Search Terms.

Highlight search terms option

Tip 376.C You can sort results that contain source code

In the results list, there’s the sort by combo box that has "Contains Code" as an option.

Sort by: Contains code option

If you are looking for some sample code, this would be to have as the filter, because it will move all these search results to the top.

help topic that contains code

Tip 376.D How to change the Web Browser Search page

I only add this because I saw this option in Tools Options, and couldn’t for the life of me figure out where the actual button or command lived. I did a few searches for “search page option” but only found the option, and nothing about the command. Only while writing this post did I accidentally or coincidentally hit it, hence why it is going here.

Web Browser Search

The option to change the page that clicking this button goes is at Tools – Options – Web Browser. (or in VS, add the Environment).

Web Browser search option

Technorati Tags: VS2005Tip,VS2008Tip