The Text Editors


Visual Studio 2005 has several text editors or word (code) processors. Each text editor is based on a common core that provides the basic set of functionality for each editor such as the selection margin, the ability to collapse nested items, and colorization. Each editor derives from this core and is customized to give you the editors for code (C#, VB, and so on), the XML editor, the HTML (or aspx) editor, and style sheet editor.

The Code Editors

It is the code editor, for our money, where the magic happens. It is here that you get down to business leveraging your favorite language to define objects and their functionality. Of course, you can write code outside the Visual Studio editor, but why would you? You can also write a novel using Notepad or do your taxes by hand. A good code editor means higher productivity, plain and simple. and Visual Studio has some of the best code editors around.

The code editor is front and center when you're working on code. It handles indentation and whitespace to make your code clean and readable. It provides IntelliSense and statement completion to free you from having to look up (or memorize) every object library and keyword. It groups code into blocks; it provides color codes for keywords and comments; it highlights errors; it shows new code relative to previously compiled code. All in all, the Visual Studio code editor does quite a bit to keep you productive.

The C# Code Editor

Figure 2.13 shows the C# code editor. Some items to note include the following:

  • The code is grouped into logical sections along the left side. You can use these minus signs to close up a whole class, method, property, or similar group. This capability allows you to hide code you are not working on at the moment. You can also create your own custom, named regions to do the same thing.

  • New code is signaled inside the section groups with a colored line. Yellow is used for new code that has yet to be saved. The highlighted line turns green after a save and disappears after you close and reopen the file. This feature allows you (and the editor) to track where you have made changes to code during your current session.

  • The name of the open code file is listed as the code window's tab across the top. The asterisk indicates the code has changed since the last time it was saved.

  • IntelliSense is invoked as you type. You can use the arrow keys to quickly find the item in the list. Hovering over the item shows details for the given item (tip text to the right). You can press the Tab key to complete the item from IntelliSense.

  • The code is highlighted in various colors. By default, keywords are blue, comments are green, text is black, your types are light blue, strings are red, and so on.

  • The two drop-downs at the top of the code editor allow you to navigate between the classes in the file (left-side drop-down) and methods, fields, and properties within a given class (right-side drop-down).

Figure 2.13. The C# code editor.


The Visual Basic Code Editor

The Visual Basic code editor works much the same way as the C# editor. Figure 2.14 shows the same code as in Figure 2.13 written inside the Visual Basic code editor. Some of the differences between the editors are as follows:

  • Horizontal lines are used to separate methods and properties within the editor.

  • The IntelliSense drop-down list is filtered into a common subset and all the possible values.

  • The code navigation drop-downs at the top of the code editor allow you to navigate the entire, active object hierarchy (including events). The left-side drop-down shows namespaces, objects, and events. The right-side drop-down shows all methods for the given type, including those you have not overridden. Those items you have implemented are highlighted in bold.

Figure 2.14. The Visual Basic code editor.


Editor Customizations

Nearly every aspect of the text and code editors can be customized to your every whim. From our experience, it seems no two developers see their code the same way (except presenters and book writers, of course). From the Options dialog box, you can change the editor's background color or the color and font of various text within the editor; you can turn on line numbering, manage indenting and whitespace, and the list goes on.

Figure 2.15 shows the Options dialog box set for Fonts and Colors. From here, you can tweak the many display items in the editor in terms of their color, font, and font size.

Figure 2.15. The Options dialog box set to Fonts and Colors.


If you dig a little deeper in the Options dialog box, you will come across the Text Editor node in the option tree. From here, you can manipulate even more settings for the text editor. For example, you can remove the horizontal procedure separators in the Visual Basic editor or turn off the automatic reformatting of code by the editor.

Even better, you can control how the editor automatically formats your code inside the C# editor. If you like to see all your curly braces on separate lines or prefer them to start on the line that starts the block, you can do so from here. Figure 2.16 shows some of the options available for formatting C# inside the editor.

Figure 2.16. Controlling code formatting from the Options dialog box.





Microsoft Visual Studio 2005 Unleashed
Microsoft Visual Studio 2005 Unleashed
ISBN: 0672328194
EAN: 2147483647
Year: 2006
Pages: 195

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net