Code editing for Eclipse's frequently used shortcut keys

Source: Internet
Author: User

Eclipse is commonly used in Java development IDE tools, skilled use of shortcut keys can improve the development efficiency, so that the coding work less, the following introduction of several commonly used code editing and completion tools

    • Renaming shortcut keys: alt+shift+r

Can be used to rename the class name, method name, property name, mouse click to rename the place, press and hold Alt+shift+r, will prompt to re-enter the name, at this time retype the new name, press ENTER to rename, regardless of the need to rename the class, or call the class name of other classes will change. If you rename a property in a class, press and hold the shortcut key two times to enable automatic renaming of the Get/set method.

    • Format code: CTRL+SHIFT+F

For formatting code, the code is written as neatly as possible, making the code easier to read, and this format can be configured with the default configuration or set itself. If you want to format the entire class, you can first CTRL + a Select all, and then perform the formatting operation. Formatting can also be implemented by right-clicking the Source-->format in the code area.

    • Automatic import of packages and removal of excess packages: Ctrl+shift+o

When writing Java code need to introduce the existing jar package, but manual packet is cumbersome, using the shortcut key Ctrl+shift+o, select the required jar package after confirmation, you can automatically import the entire class depends on all the jar package and clean the unused jar package.

    • Abstract multiple lines of code into a single method (extraction method): Alt+shift+m

In the process of code writing, a method of writing too long can affect reading and debugging, so you can put the code of a certain part of the function block as a single method. The same alt+shift+l is used to extract local variables.

Other common shortcut keys:

    • Delete code: ctrl+d to remove code
    • NEW: Ctrl + N, you can now need to create a new project
Code completion
    • Code Hint information: alt+/

Used to prompt for code, supplemental output statements, select the part of the statement that needs to be output, alt+/select the desired item.

Where main+alt+/is used to complement the main method, syso+alt+/is used to complete the SYSTEM.OUT.PRINTLN () print output code. Define your own alt+/settings on Windows--perfernces----Java--and Editor-->templates-->new, you can try it if you are interested.

    • Automatic generation of construction methods:

Alt+shift+s Open source, and then type other letters to automatically generate construction methods, automatically generate Get/set methods, and so on.

+c can generate an empty parameter construction method, +o generates a parametric construct based on local field (member variable), +r generates Get/set method. For example, type alt+shift+s before you type R to bring up the interface that generates the Get/set method

    • Code Comment:

Adding comments to your code can make your code more readable.

ctrl+/is used for single-line comments , and the shortcut keys that remove single-line comments are the same.

Select the code you want to comment type ctrl+shift+/can be used for multiline comments , the cursor in the area type ctrl+shift+\ for uncomment

    • Copy code:

Ctrl+alt+ down ARROW to copy a line of code down, ctrl+alt+ up arrow, to copy a line of code up

    • To create a blank line:

Shift+enter creates a blank line under the current line, regardless of whether the cursor is at the end of the row. Ctrl+shift+enter inserts a blank line before the current line.

    • Mobile Code:

ALT + arrow key to move the current line up or down.

    • Javadoc notes:

Java annotations are capable of generating HTML documents, even the official Android document is also called Java Doc Generation, and his shortcut keys are alt+shift+j

    • Go back to the last edit point:

Shortcut keys are ctrl+q, useful for programmers with poor memory

    • Shortcut keys for switching windows:
Eclipse in the end of the project enough, the window will switch is inevitable, how to quickly switch windows. With the mouse point, too slow, here I introduce two kinds of shortcut keys, ctrl+m switch the window view to maximize its editing window. Ctrl+f6 switch to a different class of Windows.

Code editing for Eclipse's frequently used shortcut keys

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.