Eclipse Tips & Tricks

As I am using eclipse/CDT for my bachelor project, I thought of making a small googling on some handy eclipse tips and tricks that would make my life easier. Here are some stuff I found:

  • Moving a line of code up and down: Alt + UpArrow moves a line of code up. Alt + DownArrow moves it down – you don’t have to have the entire line selected. This also retains the code comment formatting/spacing,
  • Copying a line(s) of code above or below : Ctl + Alt + UpArrow copies the currently selected line(s) above the current selection. Ctl + Alt + DownArrow copies the currently selected line(s) below the current selection.
  • Viewing all references to the selected construct : Ctl + G will display all references to the selected class, interface, method, or variable. Ctl + g will display all occurences of the selected construct.
  • Drilling down into a method or variable declaration : Click anywhere in the method or variable name, and press F3 to navigate to its definition. Press Alt + Left Arrow to navigate back.
  • Closing all windows : Press Ctl + Shift + F4 to close all editor windows
  • Renaming: Simply highlight a variable, class name or method to rename and right click to select Refactor->Rename. After entering the new name, the variable, class or method is now renamed plus anything in the whole workspace that references it.
  • Finding the matching bracket: To find a matching bracket select an opening
    or closing bracket and press Ctrl+Shift+P (Navigate > Go To >
    Matching Bracket). You can also double click before an opening
    or after a closing bracket – this selects the text between the two brackets.
  • Fix your code indentation with one key stroke (new in 3.0): . Select the code where the indents are incorrect, right click and choose Source> Correct Indentation. (or CTRL+) (Thanks to Eman for this tip!)
  • Navigating between editors: If you open a second editor while you’re editing, you can press Navigate > Backward (Alt+Left Arrow, or the back arrow on the workbench toolbar) to go back to the last editor. Also, you can quickly switch editors using the Ctrl+E keybinding which opens a list of all open editors.
  • Starting new clean sessions: A setting on the General > Editors preference page closes all open editors automatically whenever you exit. This makes start-up cleaner and a bit faster. After that, you can still stop an editor from being closed by using the Pin Editor button which appears in the workbench toolbar.
  • Viewing all keyboard shortcuts: press Ctrl+Shift+L to see a full list of the currently available key bindings
  • Importing files: You can quickly copy files and folders into your workspace by dragging them from the file system (e.g., from a Windows Explorer window) and dropping them into the Project Explorer view.
  • Switching workspace: Instead of shutting down eclipse and restarting with a different workspace you can instead use File > Switch Workspace. From here you can either open previous workspaces directly from the menu or you can open the workspace chooser dialog to choose a new one. This trick is also useful when you change certain preferences that require a restart to take effect (such as the General > Appearance preferences). To restart quickly simply switch workspaces to your current workspace.
  • Finding a string incrementally : Use Edit > Incremental Find Next (Ctrl+J) or Edit > Incremental Find Previous (Ctrl+Shift+J) to enter the incremental find mode, and start typing the string to match. Matches are found incrementally as you type. The search string is shown in the status line. Press Ctrl+J or Ctrl+Shift+J to go to the next or previous match. Press Enter or Esc to exit incremental find mode.
  • Going to last edit location: Navigate > Go to Last Edit Location (Ctrl+Q) takes you back to the place where you last made a change.
  • Converting to lowercase or uppercase: (Ctrl+Shift+Y and Ctrl+Shift+X).
  • Word completion: You can complete a prefix to a word occurring in all currently open editors or buffers by pressing Alt+/. (Ctrl+. on the Mac).
  • Toggle Comment: You can toggle comment on/off for the current line or the selected lines. Press Ctrl+/ or use the action from the drop down menu on right click in editor.
  • Maximize editor: Double-click on the editor tab to maximize editor to full window. Double-click again to restore.
  • Local history: Whenever you edit a file, its previous contents are kept in the local history. Right click in the editor and chose Compare With/Replace With > Local History….

Resources: 1 2 3 4 5

Originally Posted By Laila Hussein to Thoughts & Tips at 6/20/2008 08:55:00 PM


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: