Visual Studio .NET Tips & Tricks

Helpful information for Visual Studio .NET developers

Archive for the ‘Editor’ Category

Information about Visual Studio .NET Editor

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 »