Editor

Meta

Subscribe

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.

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.

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

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.

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.

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.

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.

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.

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.

Usage:
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.

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.

Advantages – 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.

Disadvantages

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

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.