Visual Studio .NET - Edit Menu
(Page 5 of 10 )
The Edit menu contains the text editing and searching commands that one would expect, but also includes commands useful in editing code. The most useful are:
Cycle Clipboard Ring (Ctrl+Shift+V) The Clipboard Ring is like copy-and-paste on steroids. Copy a number of different selections to the Windows clipboard, using the Edit -> Cut (Ctrl X) or Edit -> Copy (Ctrl+C) commands. Then use Ctrl+Shift+V to cycle through all the selections, allowing you to paste the correct one when it comes around. You can also see the whole clipboard ring in the Toolbox (it’s one of the panes that is visible when you’re editing a text file).
This submenu item is context-sensitive and is visible only when editing a code window.
Find and Replace/ Find in Files (Ctrl+Shift+F) Find in Files is a very powerful search utility that finds text strings anywhere in a directory or in subdirectories (subfolders). It presents the dialog box shown in Figure 2-8. Checkboxes present several self-explanatory options, including the ability to search using either wildcards or regular expressions.

Figure 2-8. Find in Files dialog box
If you click on the Replace button in the Find in Files dialog box, you will get the Replace in Files dialog box shown in Figure 2-9 and described next.

Figure 2-9. Replace in Files dialog box
Find and Replace/Replace in Files (Ctrl+Shift+H) Replace in Files is identical to the Find in Files command, described in the previous section, except that it also allows you to replace the target text string with a replacement text string.
Regular Expressions Regular expressions are a language unto themselves, expressly designed for incredibly powerful and sophisticated searches. A full explanation of regular expressions is beyond the scope of this book. For a complete discussion of regular expressions, see the SDK documentation or Mastering Regular Expressions, Second Edition, by Jeffrey E. F. Friedl (O’Reilly).
This command is extremely useful for renaming forms, classes, namespaces, projects and so on. Renaming objects is a very common requirement, often because you don’t want to be saddled with the default names assigned by Visual Studio .NET.
Renaming should not be difficult, but it can be. Object names are spread throughout a project, often hidden in obscure locations such as solution files, project files, and throughout source code files. Although all of these files are text files and so can be searched and edited, it can be a tedious and error-prone task. The Replace in Files command makes it simple, thorough, and reasonably safe.
Find and Replace/Find Symbol (Alt+F12) Clicking on this command will bring up the Find Symbol dialog box shown in Figure 2-10. This allows you to search for symbols (such as namespaces, classes, and interfaces) and their members (such as properties, methods, events, and variables).

Figure 2-10. Find Symbol dialog box
The search results will be displayed in a window labeled Find Symbol Results. From there, you can move to each location in the code by double-clicking on each result.
Go To… This command brings up the Go To Line dialog box, which allows you to enter a line number and immediately go to that line. It is context-sensitive and is visible only when editing a text window.
Insert File As Text… This command allows you to insert the contents of any file into your source code, as though you had typed it in. It is context-sensitive and is visible only when editing a text window.
A standard file browsing dialog box is presented for searching for the file to be inserted. The default file extension will correspond to the project language, but you can search for any file with any extension.
Advanced The Advanced command is context-sensitive and is visible only when editing a code window. It has many submenu items. These include commands for:
- Creating or removing tabs in a selection (converting spaces to tabs and vice versa)
- Forcing selected text to uppercase or lowercase
- Deleting horizontal white space
- Viewing white space (making tabs and space characters visible on the screen)
- Toggling word wrap
- Commenting and uncommenting blocks of text
- Increasing and decreasing line indenting
- Incremental searching (see the next section “Incremental search (Ctrl+I)”)
Incremental search (Ctrl+I) Incremental search allows you to search an editing window by entering the search string character by character. As each character is entered, the cursor moves to the first occurrence of matching text.
To use incremental search in a window, select the command on the Advanced submenu, or press Ctrl+I. The cursor icon will change to a binocular with an arrow indicating the direction of search. Begin typing the text string to search for.
The case sensitivity of an incremental search will come from the previous Find, Replace, Find in Files, or Replace in Files search (described earlier).
The search will proceed downward and left to right from the current location. To search backward, use Ctrl+Shift+I.
The key combinations listed in Table 2-1 apply to incremental searching.
Table 2-1. Incremental searching
| Key combination | Description |
| Esc | Stop the search |
| Backspace | Remove a character from the search text |
| Ctrl+Shift+I | Change the direction of the search |
| Ctrl+I | Move to the next occurrence in the file for the current search text |
Bookmarks Bookmarks are useful for marking spots in your code and easily navigating from marked spot to marked spot. There are four commands on the Bookmarks submenu (listed in Table 2-2, along with their shortcut key combinations). Note that, unless you add the item to the task list, bookmarks are lost when you close the file, although they are saved when you close the solution (so long as the file was still open).
Table 2-2. Bookmark commands
Command Key combination Description Toggle Bookmark Ctrl+K, Ctrl+K Place or remove a bookmark at the current line. When a bookmark is set, a blue rectangular icon will appear in the column along the left edge of the code window.
Next Bookmark Ctrl+K, Ctrl+N Move to the next bookmark.
Previous Bookmark Ctrl+K, Ctrl+P Move to the previous bookmark.
Clear Bookmark Ctrl+K, Ctrl+L Clear all the bookmarks.
Add Task List Shortcut Ctrl+K, Ctrl+H the current line. When a task list entry is set, a curved arrow icon () appears in the column along the left edge of the code window.
This menu item only appears when a code window is the current window.
This article is excerpted from Programming ASP.NET by Jesse Liberty and Dan Hurwitz(O'Reilly, 2003; ISBN 0596004877). Check it out at your favorite bookstore today. Buy this book now. |
Next: Outlining >>
More ASP.NET Articles
More By O'Reilly Media