Source Navigation

DrJava has many simple features to help you edit and navigate source files.

Find/Replace. DrJava has a Find and Replace utility, which is conveniently displayed as one of the tabs at the bottom of the window, rather than as a dialog blocking part of the window. The tab is first displayed when you Find/Replace from the Edit Menu (or using the keyboard shortcut, Ctrl+F), and it can be closed by clicking on the "X" button in the upper right corner of the tab (or by hitting the Escape key).

To search for a term, type it in the Find text field and click "Find Next" or "Find Previous" (or press Enter). To replace the term with another, type the new term in the Replace text field, find an occurrence using "Find Next" or "Find Previous", and then click "Replace". The "Replace/Find Next", "Replace/FindPrevious" and "Replace All" buttons help to speed up this process.

The "Find All" button accumulates all occurrences and displays them in a new, separate pane labeled "Find: word", where "word" is replaced with the search string. You can keep as many "Find All" panes open as you like. The panes keep the occurrences sorted by document and line number and allow you to jump to the source location with the "Go to" button, bookmark an occurrence using the "Bookmark" button, or to remove an occurrence from the list with the "Remove" button. Occurrences can also be underlined with different colors to make them easier to find in the Definitions pane.

There are also four checkboxes to customize each search: "Match Case","Search All Documents", "Whole Word", "No Comments/Strings", and "No Test Cases". Unchecking the first box will return case-insensitive results, checking the second box will tell DrJava to search through all of the open documents in sequence, checking the third box will ignore partial matches (i.e. it will ignore "hello" if the search text is "lo"), and checking the last box ignores instances found within comments and strings. Checking the "No Test Case" box will cause Java to ignore matches in files with test cases. Currently, this is being determined by examining the file name: If the file name ends with "", it is considered a test case and will be skilled.

Note that if "Search All Documents" is enabled, the search will not wrap to the beginning of the current document until all other documents have first been searched. DrJava can also search across more than one line of text (i.e. the search string can include line breaks). For detailed instructions on its usage, see the "Find and Replace" section in the Quickstart documents under the Help menu.

The last checkbox is "Search Selection Only". Checking this checkbox, allows the user only to Find/Replace All and disables the Search All Documents as well as No Test Cases checkboxes. The search will be limited to a highlighted portion of the document. The Find Again option after Find All with Search Selection Only has been checked only searches within the selected region likewise.

Go to Line. Selecting "Go to Line" from the Edit Menu (or hitting Ctrl+G) will display a dialog allowing you to scroll to a particular line number.

Go to File. With the "Go to File" dialog from the Edit Menu (or hitting Ctrl+Shift+G), you can quickly jump to another file. It will open a predictive input dialog, ask you to type the name of the document, and quickly narrow down the list of candidates. You can then use the cursor keys and Enter to select the file you want to view.

The "Go to File" dialog also incorporates the function of the "Go to Line" dialog: If you enter a colon (":") followed by a line number at the end of your input text, the editor will select the file and then jump to the entered line number. Example: "FooBa:123" may take you to the file at line 123.

Go to File Under Cursor. "Go to File Under Cursor", also in the Edit Menu and bound to the shortcut F6), is a special form of "Go to File": It considers the word the cursor is currently on and uses it as a starting point for your search. If there is a unique match, DrJava will open that file immediately; otherwise, this feature behaves just like "Go to File".

Fast Switching. With Fast Switching, you can easily switch between recently active documents. Simple hold down Control, and press the Back Quote key to navigate through the filenames of recently active documents. Release the Control key to switch to the document with that filename.

Line Numbering. DrJava displays the cursor's current line number and column number on the right side of the status bar at the bottom of the window. The line number is shown on the left and starts at 1, and the column number is shown on the right and starts at 0.

All line numbers can also be displayed in the left margin of the Definitions Pane, using the "Show All Line Numbers" option in the "Display Options" section of the Preferences window. The line number font can be changed in the "Fonts" section. (See Configuring DrJava.)

Bookmarks. DrJava allows you to bookmark places in your code that you deem important. If you have a project open, the bookmarks even get saved to and loaded from the project file. By pressing Ctrl-Shift-M or using the "Bookmarks" item in the Tools menu, you can display the list of bookmarks in the "Bookmarks" pane. The bookmarks are sorted by document and line number.

With the Ctrl-M keyboard shortcut or the "Toggle Bookmark" items from the Tools menu or the Definition pane's context menu, you can add and remove bookmarks. If no text is selected, "Toggle Bookmark" will add or remove a bookmark for the entire line the cursor is on. If text is selected, the selected text is bookmarked.

By selecting a bookmark in the "Bookmarks" pane and pressing the "Go to" button, you can jump to the location associated with the bookmark. You can also select one or more bookmarks and remove them with the "Remove" button, or clear the entire list with the "Remove All" button.