Navigating Code and Text
There are several ways to move throughout text:
- Mouse and navigation keys
- The Navigation bar.
- Incremental search
- Comment tasks in the Task List
- The Go To Line command
- The Go To Definition command
- The Navigate Backward and Navigate Forward buttons
Navigating with the mouse and keys
The most common way to navigate text is with the mouse and navigation keys:
- Use the arrow keys to move one character at a time, or the arrow keys in combination with the CTRL key to move one word at a time. Arrow keys move one line at a time also.
- Click a location with the mouse.
- Use the scroll bars or scroll wheel on the mouse to move through the text.
- Use the HOME, END, PAGEUP, and PAGEDOWN keys.
- Use CTRL+PAGE UP and CTRL+PAGE DOWN to move the insertion point to the top or bottom of the window, respectively.
- Use CTRL+UP ARROW and CTRL+DOWN ARROW to scroll the view without moving the insertion point.
Navigating with the Navigation bar
The Navigation bar consists of two combo boxes that display at the top of the Code Editor and allow you to navigate directly to a particular class/type or procedure/member within it. Not every project incorporates the Navigation bar.
Note The names of the combo boxes on the Navigation bar vary depending on the type of project. For example, in Visual Basic .NET projects, the boxes are named Class Name and Method Name. In C#.NET projects, the boxes are named Types and Members.
To navigate to a class or type
- Click its name in the Class Name/Types combo box in the upper left corner of the document.
To navigate directly to a procedure in a class
- Click a procedure in the Method Name/Members combo box in the upper right corner of the document.
Navigating with Bookmarks
To edit a document elsewhere and then return to your current location, add a bookmark.
To add a temporary bookmark
- Click the line you want to return to at later time.
- Click the Toggle Bookmark button . You should see the temporary (or "unnamed") bookmark symbol appear next to the line.
- Alternatively, you can press CTRL+K twice to toggle the bookmark.
To return to a temporary bookmark
- Click the Next Bookmark or Previous Bookmark button.
- Alternatively, you can press CTRL+K and then CTRL+N for the next bookmark, or CTRL+K and then CTRL+P for the previous bookmark within in a document.
Tip Another way to return to a location is by using the Navigate Backward and Navigate Forward buttons.
To remove one or more temporary bookmarks in a document
- Click the Clear Bookmarks button .
- Press CTRL+K and then CTRL+L to erase all bookmarks in the current document.
Note To delete a single bookmark, right-click the bookmark and click ToggleBookmark, or press CTRL+K and then CTRL+K again.
To add a Task List shortcut (or "Named Bookmark")
- Right-click the line.
Its name is added as a task in the Task List. You can edit the description in the Task List to change the name of the shortcut. This does not edit the line of code.
- To return to the line, double-click the task item in the Task List.
For more information, see Adding Comment Tasks to the Task List.
Navigating with comment tasks
You can create comments tasks in your code and navigate back to them later in the Task List.
To navigate to a comment task
- Create a comment task by entering a comment symbol for the language, such as an apostrophe (') character for Visual Basic and then a comment token, such as TODO:. This adds a comment task to the Task List.
- Move to another location in the document.
- Click the comment task to go to its location in your code.
Incremental search helps you navigate directly to locations in the current document as you enter the search characters.
To navigate using incremental search
- Press CTRL + I or choose Incremental Search on the Advanced sub-menu on the Edit menu.
- Begin typing the characters of the word you wish to find. As you type the characters, you are taken to matching text in the current document, beginning at the top.
Goto Line command
Use the Goto Line command to go to a specific line number.
To go to a specific line number
- In the General, All Languages, Text Editor, Options dialog box, click Line Numbers.
- Click Goto Line in the Edit menu.
- Enter the line number you want to view.
Navigating to code elements using Go To Definition
Use the command Go To Definition to immediately navigate to the parent procedure for a method call or variable definition. For example, if you have a procedure called
MyProc() and later make a call to
MyProc(), you could navigate directly to the procedure using Go To Definition.
To go to a procedure or variable definition
- Select the variable or procedure call.
- Press F12.
You are taken to the procedure or variable definition. If you want to return to the variable or procedure call, press the Navigate Backward button.
If the definition lies outside your project, the item displays in the Object Browser.
Navigate Backward / Navigate Forward buttons
Use the Navigate Backward button to navigate to previously visited locations in the document, then use the Navigate Forward button to return afterwards. (You can also press CTRL + - to navigate backward and CTRL + SHIFT + - to navigate forward.) These buttons are particularly useful when using commands that take you far away from where you are currently working and you want to return to that location quickly. Examples of such commands are Incremental Search, Goto Line, Beginning of Document, End of Document, Pasting text or inserting file contents, and Go To Definition commands. The editor remembers locations when you move in a single command more than several lines away from where you are currently working, or if you edit in a particular location that is not adjacent to the last place you edited. The goal is to remember interesting locations so that you can recall where you have been working without remembering so many locations the feature is not useful (such as every character typed, or every line entering several new lines of code one right after the other).