Tuesday, August 4, 2009

Tips and Tricks :Visual Studio .Net IDE

A collection of tips and tricks, features, for the Visual Studio .NET IDE.

Read from the book Best Kept Secrets in Dot NET from the APress publishing house.

1. Multiple copy/pastes

Ctrl+Shift+V cycles through the clipboard ring. You can copy/cut multiple times from one area of code, then go to another area and paste them one after another.

2. Previous cursor positions

Ctrl+ - i.e. Ctrl + Hyphen. This cycles you through the code positions you visited.

Ctrl+Shift+- to navigate in the opposite direction.

3. Incremental search

To incrementally search for text as you type, first press Ctrl+i. Then type the word you want to search. Hit backspace to clear a character and enter to finish. Pressing F3 after this will work as usual, i.e. search for the next occurrence of previous search.Ctrl+Shift+i is used for Reverse Incremental Search.

4. Matching brace/comment/region/quote

Ctrl+] takes you to the matching brace. It also takes you to the matching comment, region or quote depending on what is at the cursor now.

5. Vertical block selection

Press Alt and then select the area you want with your mouse.this is very useful when you have to delete line numbers or some common unwanted text in all the lines,like for eg. Using a WITH block and removing the object name from multiple lines of the code.

6. Closing/Showing support windows

There are a bunch of necessary/useful windows in the Visual Studio IDE like Properties (F4), Solution Explorer (Ctrl+Alt+L), Output Window (Ctrl+Alt+O), Task List (Ctrl+Alt+K) etc. However, they take up a lot of space. An easy way around this is to use the auto hide feature.

Open the window you want. Right click on its title and choose Auto Hide. The window will dock in whenever your mouse is not hovering over it.

7. Track things you have to do with Task List

The Task List window (Ctrl+Alt+K) allows you to keep track of the things you have to do. Right click on the Task List window and choose Show Tasks|All to see a list of tasks. Ctrl+Shift+F12 to cycle through your list of tasks.

By default, comments marked with a TODO will appear in the task list.

8. Edit Task List Comment Tokens

You can add your own set of comment tokens (like the TODO comment token). Goto Tools|Options|Environment|Task List|Comment Tokens and make your changes. You can change the priority appearance of each comment token too.

9. Add Task List Shortcut

Add a shortcut to the task list with Ctrl+K, Ctrl+H. This will add the current line to the task list.

10. Auto-complete (Almost everyone knows this one)

Press Ctrl+Space or Alt+RightArrow to auto-complete the word. Intellisense suggestions may pop up a window if there is more than one possibility.

11. Intellisense suggestions window

Press Ctrl+Shift+Space to bring up the intellisense suggestions window. When giving parameters for functions, I often need to escape the suggestions window to check another part of code. To bring it back, I used to delete a comma and then type it again; but this is easier.

12. Line numbering

Tools|Options|Text Editor|All Languages|General|Line numbers.

If you want to set this option for only one language, then choose the appropriate language instead of All Languages.


Bookmarks are available through Edit|Bookmarks. Bookmarks allow you to mark places in your code that you would want to come back to.

  • Create/Remove Bookmark – Ctrl+K, Ctrl+K
  • Move to next bookmark – Ctrl+K, Ctrl+N
  • Move to previous bookmark – Ctrl+K, Ctrl+P
  • Clear all bookmarks – Ctrl+K, Ctrl+L

14. Code Formatting

  • Auto-format selection – Ctrl+K, Ctrl+F
  • Convert to lower case – Ctrl+U
  • Convert to upper case – Ctrl+Shift+U
  • Comment selection – Ctrl+K, Ctrl+C
  • Uncomment selection – Ctrl+K, Ctrl+U

15. Outlining

I like this feature that allows me to hide code that is irrelevant to what I’m currently working on.

  • Fold/Unfold the current code block – Ctrl+M, Ctrl+M
  • Unfold all – Ctrl+M, Ctrl+L
  • Stop outlining – Ctrl+M, Ctrl+P
  • Fold all – Ctrl+M, Ctrl+O

16. Build and Debug

  • Build – Ctrl+Shift+B
  • Run – Ctrl+F5
  • Debug – F5

17. Wrapping Code

If you have long code lines, you’ll find that you do a lot of horizontal scrolling to view the entire line. As an alternative, you can wrap the code lines so you can view the code without needing to scroll.The easiest way to toggle word wrapping is by pressing Ctrl+R and then Ctrl+R again or by selecting Edit –> Advanced –> Word Wrap from the menu. When word wrapping is turned on, the horizontal scroll bar is removed and any lines of code that exceed the width of the code window will automatically wrap to the next line. This wrapping does not require any additional line-continuation characters (for VB), nor does it affect how the code is compiled
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

1 comments : on " Tips and Tricks :Visual Studio .Net IDE "

Anonymous said...

Oh my goodness! Impressive article dude! Many thanks, However
I am encountering issues with your RSS. I don't know the reason why I am
unable to join it. Is there anybody else getting the same RSS issues?
Anybody who knows the solution will you kindly respond?

Feel free to visit my site - garcinia cambogia benefits