Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

Navigating from the Source Editor

The IDE includes handy shortcuts for navigating among files, different bits of code, and different windows. The more of these shortcuts you can incorporate into your workflow, the less your fingers will have to stray from your keyboard to your mouse.

Switching Between Open Files

Besides using the Source Editor's tabs and drop-down list, you can switch between open files using the keyboard shortcuts shown in Table 5-7.

Table 5-7. Shortcuts for Navigating Among Open Files

Shortcut

Description

Alt-Left and Alt-Right

Select files in order of tab position.

Ctrl-Tab

Opens a popup box showing all open files. Hold down the Ctrl key and press the Tab key multiple times until the file that you want to view is selected. Then release both keys to close the box and display the file.

Shift-F4

Opens a dialog box that lists all open files. You can use the mouse or the arrow keys to select the file that you want to view and press Enter to close the dialog box and display the file.

Jumping to Related Code and Documentation

The shortcuts in Table 5-8 enable you to jump to parts of the current file or other files that are relevant to the selected identifier. The first six of these shortcuts are available from the Navigate menu and the Go To submenu of the Source Editor's contextual (right-click) menu. The Show Javadoc command is available straight from the Source Editor's contextual menu.

Table 5-8. Java Class Navigation Shortcuts

Command

Shortcut

Description

Go to Source

Alt-O (or Ctrl-click)

Jumps to the source code for the currently selected class, method, or field, if the source is available. You can achieve this either by pressing Alt-O with the identifier selected or by holding down the Ctrl key, hovering the mouse over the identifier until it is underlined in blue, and then clicking it.

Go to Declaration

Alt-G

Jumps to the declaration of the currently selected class, method, or field.

Go to Super Implementation

Ctrl-B

Jumps to the super implementation of the currently selected method (if the selected method overrides a method from another class or is an implementation of a method defined in an interface).

Go to Line

Ctrl-G

Jumps to a specific line number in the current file.

Go to Class

Alt-Shift-O

Enables you to type a class name and then jumps to the source code for that class if it is available to the IDE.

Go To Test

Alt-Shift-E

Jumps to the unit test for the selected class.

Show Javadoc

Alt-F1

Displays documentation for the selected class in a web browser. For this command to work, Javadoc for the class must be made available to the IDE through the Java Platform Manager (for JDK documentation) or the Library Manager (for documentation for other libraries). See Referencing JDK Documentation (Javadoc) from the Project in Chapter 3 and Making External Sources and Javadoc Available in the IDE, also in Chapter 3.

Jumping Between Areas Where You Have Been Working

When you are working on multiple files at once or in different areas of the same file, you can use the "jump list" shortcuts to navigate directly to areas where you have been working instead of scrolling and/or switching windows. The "jump list" is essentially a history of lines where you have done work in the Source Editor.

You can navigate back and forth between jump list locations with the Alt-K (back) and Alt-L (forward) shortcuts. Use Alt-Shift-K and Alt-Shift-L to navigate files in the jump list without stopping at multiple places in a file.

Jumping from the Source Editor to a File's Node

When you are typing in the Source Editor, you can jump to the node that represents the current file in other windows. This can be useful, for example, if you want to navigate quickly to another file in the same package or you want to browse versioning information for the current file.

See Table 5-9 for a list of available shortcuts.

Table 5-9. Shortcuts for Selecting the Current File in a Different Window

Command

Shortcut

Select the node for the current file in the Projects window.

Ctrl-Shift-1

Select the node for the current file in the Files window.

Ctrl-Shift-2

Select the node for the current file in the Favorites window.

Ctrl-Shift-3

  • + Share This
  • 🔖 Save To Your Account