Editing Code Efficiently

Sometimes, you might find that the editor window is just too small, especially with all the extra little metadata windows and tabs surrounding it. Try this: Double-click the tab of the source file that you want to edit. Boom! It's now nearly the full Eclipse window size! Just double-click to return it to normal.

Ever wish you could see two source files at once? Well, you can! Simply grab the tab for a source file and either drag it over to the edge of the editor area or to the bottom. You then see a dark outline, showing where the file will be docked—either side-by-side with another file or above or below another file. This creates a parallel editor area where other file tabs can be dragged, as well.

Ever wish you could see two places at once in the same source file? You can! Right-click the tab for the file in question and choose New Editor. A second editor tab for the same file comes up. With the previous tip, you can now have two different views of the same file.

Ever feel like you get far too many tabs open for files you're no longer editing? I do! There are a number of solutions to this problem. First, you can right-click a file tab and choose Close Others to close all other open files besides the chosen one. You can quickly close specific tabs by middle-clicking with a mouse on each tab. (This even works on a Mac with a mouse that can middle click, such as one with a scroll wheel.) Finally, you can use the Eclipse setting that limits the number of open file editors:

1. Open Eclipse's Preferences dialog.

2. Expand General, choose Editors, and check Close Editors Automatically.

3. Edit the value in Number of Opened Editors Before Closing.

I find eight to be a good number to use for the Number of Opened Editors Before Closing option to keep the clutter down, but have enough editors open to still get work done and have reference code open. Note also that if you check Open New Editor under When All Editors Are Dirty or Pinned, more files will be open if you're actively editing more than the number chosen. Thus, this setting doesn't affect productivity when you're editing a large number of files all at once but can keep things clean during most normal tasks.

0 0

Post a comment