Visual Studio .NET Tips & Tricks

Helpful information for Visual Studio .NET developers

Tip: VS.NET Add-ins

Posted by Ion Toma on April 17, 2006

VS.NET can be adapted and extended to automate the development process (like repetitive tasks) or to provide functionality that is missing (development tools, etc). The development environment can be extended using macros or add-ins. What is nice is that most of the add-ins are free to download and use.

Example: We can use GhostDoc, a free add-in for Visual Studio, to automatically generate XML documentation comments. GhostDoc is looking at the information in base classes or implemented interfaces. Also, it can generate the comments based on then ame and type of methods, properties or parameters. 

1. Before using GhostDoc
void checkLogin( string strUsername, string strPassword){

2. After installing GhostDoc, right-click on the method declaration and choose “Document this”. The following comments are generated:
/// <summary>
/// Checks the login.
/// </summary>
/// <param name="strUsername">The username.</param>
/// <param name="strPassword">The password.</param>
void checkLogin( string strUsername, string strPassword){

In this example, GhostDoc has automatically generated the documentation for our method based on the name of the method and the name of the parameters. Basically, it gives a starting point, we can easy add more information.

Note: a nice article can be found at, it is called "Visual Studio Add-Ins Every Developer Should Download Now"

Flash Demonstration

Posted in Add-ins/Plugins, Advanced, Miscellaneous, VS.NET 2003, VS.NET 2005 | 1 Comment »

Tip: Most useful shortcuts in VS.NET

Posted by Ion Toma on April 17, 2006

Switching between Windows:

Ctrl+F6  – navigate between various panes that appear in the base code editing window.
Shift+Alt+Enter – full-screen mode at any time. In full-screen mode, only the active window is visible in full screen.
Alt+F6/Alt +Shift+F6 – move cursor away from the main editing section into docked windows like Properties, Help, Dynamic help, Server Explorer (if these winows are open).
F7 – Jump to Code Behind/Base Code editing window

Ctrl+Shift+V   – cycle through the clipboard ring.
Ctrl+- (Ctrl + Hyphen) – similar with Internet Explorer, very easy to navigate from page to page.
Ctrl+Shift+- – cycles in the opposite direction.
Block Selection: – press Alt and then select the area you want with your mouse.
Line No in Code – Tools>Options>Text Editor>All Languages>General>Line numbers.
Ctrl+] :matching brace/comment/region/quote
F4: Property Window
Ctrl+Alt+L – Solution Explorer
Ctrl+Alt+O – Output Window
Ctrl+Alt+K – Task List
Ctrl+Shift+Space – intellisense window.
Ctrl+R – Word Wrap

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

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

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

F5 – Start Application in debug Mode
Ctrl+F5 – Start Without debugging
F11 – Step into
F10 – Step over.
Shift + F11 – Step Out.
Shift + F5 – Stop debugging.
Ctrl+Shift+F5 – Restart Debugging.

Posted in Advanced, Beginner, Coding & Debugging, Intermediate, Miscellaneous, VS.NET 2003, VS.NET 2005 | Leave a Comment »

Tip: Select Block Text

Posted by Ion Toma on April 17, 2006

Normally, if we want to select several lines of text, this is done on line-by-line base.
With block selection, by holding the ALT key while dragging the cursor within the code window, we can select a rectangle, rather than selecting it line by line. We can call it vertical block selection. It can be very useful when we have to delete unnecessary text, like in the following example. Please take a look at the Flash Demonstration to see it in action.

Flash Demonstration

Posted in Beginner, Editor, VS.NET 2003, VS.NET 2005 | Leave a Comment »

Tip: Bookmarks

Posted by Ion Toma on April 17, 2006

Bookmarks can be used to mark places in the code, like the code that you might want to jump back and forward. Bookmarks can be related to task list shortcuts, kind of the same functinality.

The bookmarks can be setup very easy, by pressing CTRL+K, CTRL+K to leave bookmark. For navigation, you can press CTRL+K, CTRL+N to move to the next bookmark, or CTRL+K,CTRL+P for the previous bookmark.


Flash Demonstration

Posted in Beginner, Coding & Debugging, Editor, VS.NET 2003, VS.NET 2005 | Leave a Comment »

Tip: Word-wrap

Posted by Ion Toma on April 17, 2006

In case we got code that goes too long, we have to scroll out of the screen to see the whole line.
In Visual Studio .NET, there is an option to wrap the text around, we don’t have to scroll horizontal to see the whole line

To wrap the text around, hit the following combination:
CTRL+R, CTRL+R in .NET 2003
CTRL+E CTRL+W in .NET 2005
Disadvantage: it make the code look a little bit messy.  But working with line numbers, this may be avoided. Tools > Options and select a checkbox that allows to see the line numbers.

Note: this tip can be used also in the case when we have to move the mouse over an error description to be able to see the long line. Just hit CTRL+R CRTL+R in Output pane and the error description will wrap around.

Posted in Beginner, Coding & Debugging, Editor, VS.NET 2003, VS.NET 2005 | Leave a Comment »

Tip: Add Line Numbers to Your Code-Behind Classes

Posted by Ion Toma on April 17, 2006

Adding Line numbers to your code can be very helpful when discussing the code with someone else. 


How to add line numbers to the code: from Tools menu, select Options, and then the Text Editor / C# or Basic options. Select then the "Line numbers" checkbox om the right-side.


Also, it works well with word wrap, you can see when a line starts and ends.
Another way to bring lines to your code is using Macro Explorer Tool window; there is a build in macro built-in that allows to turn on/off the line numbers.

Note: the line numbers are in the code, they are just displayed in a column to the left. 

Posted in Coding & Debugging, Editor, Intermediate, Testing, VS.NET 2003, VS.NET 2005 | Leave a Comment »

Tip: Outlining

Posted by Ion Toma on April 17, 2006

To view the overall structure of the code, in VS.NET we can expand and close code regions for classes/procedures/functions.

This is a built-in function of the code editor. Collapse everything to definition, by clicking right and select Outlining. It will shows only the signature lines, to get a summary view of everything in a particular code.


Posted in Editor, Intermediate, VS.NET 2003, VS.NET 2005 | Leave a Comment »

Tip: Clipboard Ring

Posted by Ion Toma on April 17, 2006

You may noticed from using Microsoft Office, that anytime you copy (CTRL+C) & paste (CTRL+V) a piece of text, it adds to the clipboard ring, which stores up to 20 entries of code snippets or HTML code. In Visual Studio, the entries from Clipboard Ring are stored in a toolbox, you can navigate thorough all these entries, can drag and drop any entry or using CTRL+SHFT+V you can cycle through clipboard entries, and easily drop it in your code.

1. Copy a selection using Ctrl-C (Copy).
2. Pressing Ctrl-V will paste the last item you copied.
3. Pressing Ctrl-Shift-V will also paste the last item in the clipboard. If you want to retrieve the second, or last item you inserted into the clipboard, simply keep pressing Ctrl-Shift-V to cycle through the items in the clipboard. Or just drag and drop any entry.

Clipboard Ring - Image 6

Posted in Editor, VS.NET 2003, VS.NET 2005 | Leave a Comment »

Tip: Incremental Search

Posted by Ion Toma on April 17, 2006

To search, ussally you have to enter a CTRL+F and type the whole string and the search through the results.
Incremental search has a different behaviour: when you type CTRL+I, the code editor will move around as you type in and find any instance of the code you type in.

How to use it

Press Ctrl+I for incremental search mode. You can then enter text and drill down to the selection in the file that matches what you have typed.  The  incremental search can be initiated with Ctrl+I to see the last search pattern. Ctrl+Shift+I initiates a reverse incremental search, or switches a forward search to a reverse search.
Search - Image 5

 – There aren't any dialogs in incremental search interface, where the interactive search indicator is a cursor change after you press CTRL+I.
 – Less time is lost to search.  The search begins as soon as the first character is typed. You know immediately when you've got a good enough match and you can stop typing.
 – It's interactive, immediate search feedback alows you to adjust your search strategy in real time.


Incremental search doesn't look for text in hidden regions, but an regular search does it.

Posted in Beginner, Editor, Levels, VS.NET 2003, VS.NET 2005 | Leave a Comment »

Tip: Edit ASP.NET configuration file

Posted by Ion Toma on April 16, 2006

There is general belief that in VS.NET there is no good editor for ASP.NET configuration file or any kind of a viewer for navigating the hierarchy. As we know, the config file is in XML format and usually is a complex file, it will save a lot of time if we have a way to find fast an element,

In fact, there is a way in VS.NET to deal with this problem: go to View > Other Windows > Document outline. The result is a logical navigation on the different nodes in the configuration file (which is in XML format) and you can drill down, find things that you want to take a look at.
The same principle applies to ASPX files, the Document Outline show the different controls we may have in that file. If we switch to HTML mode, then it will show also the tags and metatags in the HTML, this will save a lot of time for complex/big files.

Configuration File - Image 4

Posted in Editor, Intermediate, VS.NET 2003 | Leave a Comment »