The code editor has all the features you might expect in a program editor, such as
cut, paste, search, and replace.2 You access these features via the usual Windows
shortcuts (Ctrl+X for cut, Ctrl+V for paste, and so on). If you like icons, you have
them as well, on the context menu inside the Code window or the Edit menu.
Check out the Edit menu for the keyboard shortcuts or look at the Help topic on
“Editing, shortcut keys” for a full list. The shortcut Ctrl+I activates an incremental
search facility, for example.
You also have the amazingly useful IntelliSense feature, which tells you what
methods are available for a given object or what parameters are needed for a
function, as you can see in Figure 2-9. You usually see IntelliSense at work when
you hit the “.”, which is ubiquitous in accessing functionality in Visual Basic.
2. You can even automatically add line numbers by working with the dialog box you get by
choosing Tools|Option|Text Editor
TIP If you are accustomed to using the incredibly useful Comment Block and
Uncomment Block tools introduced in VB5, they are again available. Only now,
thankfully, these default to being available in the standard toolbars that show up
in the IDE as opposed to being on the Edit toolbar, where they were relegated to
obscurity in VB6.
NOTE Certain options, such as Option Explicit, are now the defaults and do not
show up in your Code window as they did in VB6. (Although we still have a habit
of putting them in to make sure!) See the next chapter for more on these options.
Chapter 2
20
You usually get the global features of the editor by working with the Tools|Options
dialog box and choosing the Text Editor option, as shown in Figure 2-10. This
Options dialog box is quite different from its counterpart in earlier versions of
VB6, so we suggest exploring it carefully. To set tab stops, for instance, click on the
Text Editor option as shown in Figure 2-10. Once you do that, you can either set
tabs on a language-by-language basis or solely for VB. You can also change how the
indentation of the previous line affects the next line from None to Block (where
the cursor aligns the next line with the previous line) to a Smart setting (where the
body of a loop is automatically indented) as good programming style would indicate.
(You can select tabs and apply smart formatting after the fact using Ctrl+K, Ctrl +F
or via the Edit|Advanced|Format Selection option. Note that when you are using
Smart Tabs, selecting a region and pressing Shift+Tab (to manage indents) also
reformats.)
Figure 2-9. IntelliSense at work
Figure 2-10. The Options dialog box
The VB .NET IDE: Visual Studio .NET
21
One neat new feature in the Editor is the ability to “collapse” regions of code
so that all you see is the header. Notice the lines of code in Figure 2-11 with the + signs
next to them. Clicking on one of these would expand the region, as it is called in
VS .NET. Hovering the mouse over the ellipses (the three dots) would show the
collapsed code. The Edit|Outlining submenu controls this feature.
There are a few other nifty features of the VS .NET editor that will be new to
experienced VB programmers, and we take them up next.
Figure 2-11. Collapsed regions in the editor
TIP You can create your own named regions as well by simply mimicking what
you see in Figure 2-11. Place a #Region "NameOfRegion" at the beginning of the
block you want to potentially collapse, and place a # End Region line after it.
TIP The online help topic called “Editing Code and Text” and its various links
are particularly useful for learning how to use the editor in the IDE. There are
quite a few very useful rapid navigation features available, for example.
No comments:
Post a Comment
This is Good Computer Information Blog.they will give
best information about computer.