1 / 39

Visual Studio tips, tricks, and traps

Visual Studio tips, tricks, and traps. Visual Studio is a rich and deep product. Here are a few VS 2005 shortcuts and interesting things that make your work easier. Using bookmarks effectively.

mauve
Download Presentation

Visual Studio tips, tricks, and traps

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Visual Studio tips, tricks, and traps Visual Studio is a rich and deep product. Here are a few VS 2005 shortcuts and interesting things that make your work easier.

  2. Using bookmarks effectively • Bookmarks are a way to mark parts of your code—for the purpose of making it easy to get back to that position in the code • Bookmarks are, at first blush, not worth the work • However, by poking around in Visual Studio just a little, you’ll quickly see how once you learn how to use bookmarks, at least for large projects, you’ll never do without them!

  3. Bookmarks Code

  4. Use Edit>Bookmarks>Toggle Bookmark to toggle a bookmark, or Ctrl/B + T

  5. Bookmarks are identified as a small blue rectangle in the left margin. Bookmarks ride with the line with which they are associated.

  6. The Bookmark menu

  7. The Bookmark window View>Other Windows>Bookmark Window Press F2 to rename a bookmark Rename the bookmarks and put them in a folder Group bookmarks in folders that are named for the files in which the bookmarks reside

  8. Visual Studio mystery • Where is the SLN file for my Web project? f:\_code\web\PaloozaTest1 A new Web site is created. However, there is no solution file, the SLN file, in its folder. Why?

  9. The location of the original SLN file • Use Tools>Options>Projects and Solutions… The location of the original SLN file is governed by the Projects and Solutions “projects locations” setting C:\Documents and Settings\roger\My Documents\Visual Studio 2005\Projects

  10. Gotcha! • The enigmatic SLN file!

  11. Why am I saying “original” SLN file? • The SLN file isn’t really important • If you delete, you can still open a Web site project by simply using File > Open Web Site and selecting the root folder of the Web site you want to open • If you delete the original SLN, or if you move the project, it looses its link with the original SLN file • For most Web site projects, I don’t pay much attention to the SLN file

  12. Creating a new SLN file If you open a Web site that has lost its link with its SLN file (or if the SLN file has been deleted), it gets created for you—after you tell Visual Studio where to put it.

  13. Visual Studio mystery • What causes this?! The number is parentheses seems to come from nowhere sometimes. What gives?

  14. Duplicate project names? • If you create two projects with exactly the same name, in different folders (would have to be, right)… • Visual Studio tries to create a folder and a file for that project in your default projects location • Because it can’t create two folders with the same name.

  15. The mystery solved • For example, I created a PaloozaWeb1 project in one folder, and then another PaloozaWeb1 project in another • Here’s what is in the default projects folder • The (2) was added to the second to differentiate it

  16. Do you hate a messy Start Page? Yuchh!

  17. Keep your MRU list clear • MRU entries are written to the registry and there isn’t an easy to clear them • I wrotethis programto clearthe MRU Program available with Palooza downloads

  18. Favorite keystrokes • Use the clipboard ring • Ctrl/Shift/V – cycles through the contents of the clipboard • Incremental search • “Modeless” quick searches • Ctrl/I • Find in files to find something in your project • Ctrl/Shift/F

  19. Favorite keystrokes • Visual Studio 2003 made very effective use of Ctrl/Tab and Ctrl/Shift/Tab to move to the next or previous document window • In Visual Studio 2005, they replaced that great feature with this boneheaded dialog:

  20. You might like this. I hate it! All I want is a quick way to navigate back and forth through next and previous windows.

  21. Ctrl/Tab: Stickin’ it to the man! • Keyboard remapping to the rescue • Use Tools>Options>Environment>Keyboard to remove the keyboard bindings for Window.NextDocumentWindowNav and Window.PreviousDocumentWindowNav • Then, assign Ctrl/Tab to Window.NextDocumentWindow and Ctrl/Shift/Tab to Window.PreviousDocumentWindow • Now, all is right with the world

  22. Go full screen • Use Shift/Alt/Enter to toggle between normal view and full screen view. • Full screen view maximizes your editing window

  23. Shift/Alt/Enter takes you from this

  24. To this (back back again). Full screen mode gives you a chance to see all your code, but quickly restore the windows you were using. Thanks to Dean Bathke!

  25. Favorite keystokes • Move to matching token • Moves to matching brace or paren • Or, to matching BegSr/EndSr, Do/Endo, et al • Ctrl/] • Go to definition • OK, this isn’t a keystroke, it’s a mousestroke! • Put the cursor on a variable or method name, right-click it, and select “Go to defintion” • Takes you to the member definition

  26. Editor goodies • Did you know that URLs are hot in your code? • Embed links to your help or to source documents • Enabled by default, but “Enable single-click URL navigation in” Text Editor options

  27. Make sure this is checked to enable hot URLs.

  28. Editor goodies • Turn line numbering on • Check “Line numbers” in Text Editor options • Shows line numbers in the left margin

  29. Make sure this is checked to see line numbers

  30. It’s nice to see line numbers, but it’s typically pointless. The reason you want line numbers visible is that when they are visible the “line selector” area for the mouse is substantially wider.

  31. Use Sara Ford’s trick for adding vertical indention rules to the Visual Studio editor. These rules are great for beginners learning how to indent their code. My preference is to use a very light gray rule. You can just barely see them in this shot. Get the registry hack here: http://blogs.msdn.com/saraford/archive/2004/11/15/257953.aspx

  32. Here is the same screen shot with the rules made a little more obvious so that you can see them.

  33. Use the Libretto’s code snippets to reduce the code you need to write • The Libretto is a Web app that offers AVR-specific snippet templates • http://developer.asna.com/libretto • It’s always up, it works, and it’s free!

  34. http://developer.asna.com/libretto

  35. Most Libretto templates have promted replaceable tokens. After you provide their values, click “Replace” or press Enter and the code shown on the left is on your clipboard. http://developer.asna.com/libretto

  36. http://developer.asna.com/libretto

  37. Did you ever forget where a project is? • First, shame on you! • But, just right-click a file’s tab and select “open containing folder” • An Windows explorer Window will be opened over the folder where that file is • Note that you can also copy the file’s fully qualified name to clipboard with this right-click as well.

  38. Quickies • Use the Build toolbar (right-click on the menu and show the Build toolbar) for 1-click builds • Use two monitors—delivers exponential boost to your productivity • Use SUBST to map drives—an old DOS trick lives! • Investigate the macros that come with VS • Use Vault! You’re crazy if you don’t.

  39. Helpful links • Sara Ford’s blog—great VS tips • http://blogs.msdn.com/saraford/ • Microsoft Visual Studio guided tour • http://msdn.microsoft.com/vstudio/tour/vs2005_guided_tour/default.htm • Microsoft Visual tips and tips • http://msdn2.microsoft.com/en-us/library/bb245788(vs.80).aspx • Free Visual Studio Book (PDF) • http://www.infoq.com/minibooks/vsnettt • Zoomit – great screen magnification tool • http://www.microsoft.com/technet/sysinternals/utilities/zoomit.mspx

More Related