Easy Tutorial
❮ Nodejs Callback Func Java Inner Class Intro ❯

Common Eclipse Shortcuts and Tips

Category Programming Technology

Java developers often use Eclipse or MyEclipse integrated development environments. Practical Eclipse shortcuts and tips can save a lot of time and improve work efficiency during daily development. Below, I share some commonly used Eclipse shortcuts and tips based on my own development experience.

15 Common Eclipse Development Shortcuts and Tips

1. alt+? or alt+/: Auto-complete code or suggest code

This is my favorite shortcut combination. Especially when typing "syso" and pressing these two keys, it automatically completes System.out.println();. Eclipse defaults to showing method suggestions after a ., but if the suggestion disappears and you want to see it again, you need to re-enter the . before the class or variable. However, using these two keys together can also prompt suggestions. Try it. If you type "for," and there's a local variable to iterate over, it will prompt to choose between for each, for(int;;), or while() and automatically generate the code.

2. ctrl+o: Quick outline view

If you want to view methods in the current class or a specific method without scrolling or using the search function, use ctrl+o. It's especially useful when opening or tracing into a class with many methods, as it lists all methods and properties. Just enter the method name you want to query and press enter to jump directly to that location.

3. ctrl+shift+r: Open resource list

This is one of the most time-saving shortcuts and is frequently used by me. It allows you to open any file in your workspace by typing the first few letters of the file name or mask, like "applic*.xml". Unfortunately, this shortcut is not available in all views.

4. ctrl+shift+f: Format code

By default, it wraps at 80 characters, but this can be set. It can also reformat code according to coding style settings. Our team has a unified code format, documented on our wiki. To do this, open Eclipse, select Window Style, and set Code Formatter, Code Style, and Organize Imports. Use the Export feature to generate configuration files, which we place on the wiki for everyone to import into their Eclipse.

5. ctrl+e: Quick editor switch

This shortcut helps you navigate between open editors, especially useful when many files are open, making it very efficient.

6. ctrl+page down or ctrl+page up: Quickly switch between tabs

This allows you to browse previous and next tabs, making page switching very fast and helpful.

7. shift+enter and ctrl+shift+enter: Create blank lines above or below the current line

Shift+enter creates a blank line below the current line, regardless of where the cursor is. Ctrl+shift+enter inserts a blank line above the current line. These shortcuts are very helpful; you might not be used to them at first, but they become very convenient after frequent use.

8. Alt+arrow up/down: Swap lines or move the current line up or down

This is another time-saving shortcut. It moves the current line up or down. It's particularly useful in try/catch blocks.

9. Control+Alt+arrow up/down: Copy highlighted lines

This is also a useful shortcut, allowing you to copy the current code to the line above or below.

10. ctrl+m: Maximize the current editor window

Large displays can improve efficiency. Ctrl+m maximizes the editor window, and pressing it again restores the window to normal size.

11. ctrl+/: Auto-comment the current line or selected lines

This automatically comments out the current line or multiple lines with //, and *ctrl+* can undo the comment.

12. ctrl+shift+/: Auto-comment the selected code block

This comments with /* */ (for programming language code), and ctrl+shift+\ can undo the comment.

13. ctrl+d: Delete the current line

This is very useful, especially during debugging, to delete the current error. Combined with ctrl+z for undo, it's very handy.

14. ctrl+shift+x and ctrl+shift+y: Convert letters to uppercase or lowercase

This shortcut is commonly used in SQL statement writing. It's recommended to use uppercase for SQL keywords for better readability, especially in long SQL statements.

15. ctrl+shift+o: Automatically import packages and remove unused packages

This shortcut is also very convenient. When using a class from another package without importing it, a red wavy line appears. Pressing this shortcut removes the warning and normalizes the code. If multiple packages contain the same class, it prompts you to choose. It can also quickly remove unused imports, often caused by copying and pasting code.

Additional Tips:

Lock the command line window: In the command line view (Window -> Show View -> Other -> Basic -> Console), try locking the console output to prevent scrolling.

Use the Ant view: In my Java or Debug mode, I like to display the Ant view for quick Ant task execution. Find it through Window Ant. Place the Ant view in a corner of the screen and add build.xml files via the "Add Build Files" button. In version 3.1, it even supports Ant debug scripting.

Auto-traverse a collection: for + Control-Space: If you don't know, Control-Space is auto-completion. In Eclipse, you can auto-complete structures. Within an array or collection, type "for" and press Control-Space. Eclipse will ask which collection you want to traverse and auto-complete the loop code.

Use hierarchical layout: In the Package Explorer view, the default (flat) layout confuses me, showing the full package name in the navigation tree. I prefer the package and file system view in Eclipse, called hierarchical layout. Switch to this mode by clicking the down button in the Package Explorer, selecting Layout, and then Hierarchical.

Display multiple files at once: You can browse multiple files. Drag inactive editor windows to the bottom or side scrollbars of the active window to open them. This is the best way I can describe this trick.

Open two Eclipse instances simultaneously: To merge changes from one CVS branch to another, I like to do this by opening two different workspaces in Eclipse. This allows me to compare changes from the latest CVS version (right-click the project and select Compare Latest from HEAD) and merge each change into the other CVS branch. The easiest way to start multiple Eclipses is using Eclipse with Launcher.

Implementors plugin: Install a plugin that jumps to an interface implementation. If you're a dependency injection fan or working on well-written interfaces, this plugin speeds up code navigation. You can find it on SourceForge.

Auto-generate getter and setter methods: In the corresponding POJO, right-click the blank area, select Source, then Generate Getters and Setters, and choose which properties to generate methods for. Click OK. This saves time, especially with many member variables.

Complete List of Eclipse Shortcuts:

-Ctrl+1: Quick fix (a classic shortcut)

-Ctrl+D: Delete current line

-Ctrl+Alt+↓: Copy current line to the next line (duplicate)

-Ctrl+Alt+↑: Copy current line to the previous line (duplicate)

-Alt+↓: Swap current line with the next line (useful, saves cutting and pasting)

-Alt+↑: Swap current line with the previous line (same as above)

-Alt+←: Previous edited page

-Alt+→: Next edited page (relative to the previous one)

-Alt+Enter: Show properties of the selected resource (project, file, or folder)

-Shift+Enter: Insert a blank line below the current line (cursor can be anywhere)

-Shift+Ctrl+Enter: Insert a blank line above the current line (same principle)

-Ctrl+Q: Jump to the last edited location

-Ctrl+L: Jump to a specific line (useful for long code)

-Ctrl+M: Maximize the current editor or view (reverse if pressed again)

-Ctrl+/: Comment the current line, press again to uncomment

-Ctrl+O: Quick outline

-Ctrl+T: Quick display of the current class's inheritance structure

-Ctrl+W: Close the current editor

-Ctrl+K: Quickly locate the next occurrence of the selected word

-Ctrl+E: Quickly display a dropdown list of the current editor (bold if not displayed)

-Ctrl+/(keypad): Collapse all code in the current class

-Ctrl+×(keypad): Expand all code in the current class

-Ctrl+Space: Code assistant to complete some code insertion (usually conflicts with the input method, can be replaced with Alt+/)

-Ctrl+Shift+E: Manage all currently open views (can choose to close, activate, etc.)

-Ctrl+J: Forward incremental search (each letter you type quickly matches a word in the editor, very useful for finding a specific word)

-Ctrl+Shift+J: Reverse incremental search (same as above but searches backward)

-Ctrl+Shift+F4: Close all open editors

-Ctrl+Shift+X: Convert selected text to uppercase

-Ctrl+Shift+Y: Convert selected text to lowercase

-Ctrl+Shift+F: Format the current code

-Ctrl+Shift+P: Locate the corresponding matching character (e.g., {})

The following shortcuts are commonly used in refactoring, mostly starting with Alt+Shift:

-Alt+Shift+R: Rename (one of my favorites, especially for renaming variables and classes, saves a lot of manual work)

-Alt+Shift+M: Extract method (one of the most used refactoring methods, especially useful for large blocks of messy code) -Alt+Shift+C: Modify function structure (very practical, if N functions call this method, modify once to fix all)

-Alt+Shift+L: Extract local variable (can directly extract magic numbers and strings into a variable, especially useful when called multiple times)

-Alt+Shift+F: Convert local variables in a class to field variables (a practical feature)

-Alt+Shift+I: Combine variables (might be slightly inaccurate to say "Inline")

-Alt+Shift+V: Move functions and variables (not commonly used)

-Alt+Shift+Z: Refactoring's regret pill (Undo)

>

Author: Java我人生 (Chen Leixing)

Original source: http://blog.csdn.net/chenleixing/article/details/44600587

** Click to share notes

Cancel

-

-

-

❮ Nodejs Callback Func Java Inner Class Intro ❯