Eclipse shortcut keys and tips for use

Source: Internet
Author: User

Shortcut keys Function
Ctrl +/ Double Slash comment
Ctrl + shilft +/ Block annotations
Alt +/ Code hints
CTRL + I (or CTRL + Shift + F) Formatting code
Ctrl + D Delete When moving forward
Ctrl + W Close the active window you are editing.
Ctrl + F Search, replace
Ctrl + H Advanced Find
Ctrl + L Navigate to the first few lines
CTRL + Alt +↓, CTRL + Alt +↑ Copies the current line to the next (top) row. Simple copy function than CTRL + C to be easy to use (skip the paste step), mainly used in writing code, need to move the code place.
Alt +↓, Alt +↑ Move a single-line (multiline) code. is also better than CTRL + C shortcut keys.
Ctrl + Shift + R Quickly locate files (any type) based on file name (fuzzy query)

This document mainly introduces the skill that the person thinks more practical, the common skill does not do the introduction. Data from the network, and then concentrate on their own.

First, the Utility class shortcut key

1 familiar shortcut keys for common use

CTRL + C (copy), ctrl+x (cut), CTRL + Z (undo), Ctrl+f (Find), ctrl+h (search for files or strings), Ctrl+y (Redo),

ctrl+/(double slash comment),ctrl+shilft+/(block comment)

alt+/( code hint ): This shortcut is a good helper for the user to edit, can provide users with the content of the assistant, do not worry about the method and the name of the property, when not the whole class, methods and attributes of the name, more experience the "alt+/" shortcut key benefits.

ctrl+shift+f( format code )

2 Encoding Helper Classes

1) ctrl+d

Deletes the current row.

2) ctrl+alt+↓, ctrl+alt+↑

Copies the current line to the next (top) row. Simple copy function than CTRL + C to be easy to use (skip the paste step), mainly used in writing code, need to move the code place.

3) alt+↓, alt+↑

Move a single-line (multiline) code. is also better than CTRL + C shortcut keys.

4) alt+shift+j

Add comments to classes, methods, variables, first row of classes, methods, variables, and press this key combination. The reason for the proposed use is to standardize the code. Now many people do not write their own classes, methods, variables and Doc document comments, can not generate the API documentation. So everyone must add a class, a method, and a standard doc document comment to it. (There is a simpler way to add class annotations, see the configuration section later)

5) ctrl+1

Fixed shortcut key, prompt code error reason and handling method. The same functionality as the Red Fork in the code. This is a very common feature. Typically used to modify syntax errors. But the individual feels that it is more convenient to use the method (or parameter) of the interface to increase the method (or parameter). For example, when you want to add a method to an interface or class, just write your method and parameters (not defined) in the place you want to call, Ctrl+1, select Create Method ... You can automatically add the method you want, saving a lot of code to write. The essence is to first make a wrong syntax, let the system automatic repair function to help us complete the code.

6) ctrl+2

Modify the variable name to define the variable. Pressing the shortcut key will pop up a list of shortcuts (the bottom right corner of the window) and select the action you want.

3 Quick Position---shortcut keys

1) ctrl+shift+r (very useful)

Quickly locate files (any type) in Eclipse. With this, just remember the approximate name of the file, you can search through the fuzzy query. There is no need to open one of the modules of a Java class, a file to find. In the study of the source code, it is also indispensable.

2) Ctrl+o

Finds a variable or method in a file. Our general practice is to pull the scroll bar one after the other to find their own way. Now just type in the previous name of the method and you can quickly filter out the method you want.

3) Ctrl+q

Returns the last edited place. Sometimes we open too many Java classes, and when we need to go back to the place we just edited, this key can be put into place one step at a time. Very useful.

4) Ctrl+t

Open the Declaration of a method. With this, you can quickly find the class or interface to which this method belongs, and view the contents of the method.

5) ctrl+w .

Close the active window you are editing.

6) Ctrl+k(look down), ctrl+shift+k(find up)

After you have selected a string, you can press the shortcut key to quickly navigate to the position where the character is to appear again in the current document. Ctrl+f (find) useful? But compared to this, it is a bad one. Because you do not need to open the Find window, you do not need to enter the characters you are looking for, just select what you are looking for. Useful when looking for variables, methods.

7) Ctrl+j

There is a limit to the search function above, if there are no characters to look for, it is difficult to enter it manually. CTRL +J, you can do a favor. Just press this key, enter the character you want to jump, you can see the cursor in the page constantly jumping, navigate to what you want.

8) Ctrl+l

Navigate to the first few lines

9) Ctrl+e

Select the File window to activate

10) CTRL +, CTRL +. (or alt+left,alt+right)

Locate the location (or error) that you browsed on (previous) step. You've browsed through a few Java files, and when you go to another file and want to go back to the file you just accessed, use this key. or through the buttons on the toolbar.

One) alt+shift+z

Select a piece of code, press this key to see what appears?? This should be what you want.

) in the Package Explorer the button in the upper right corner of the view

A button with a left and right arrow that is in the pressed state allows you to synchronize the files in the open file with the Navigation view.

4 other

1) Maximize ctrl+m window

2) Ctrl+shift+l (open shortcut key panel), Ctrl+shift+l (2) Press L two times (open Shortcut configuration panel)

3) Alt+shift+t keys for a panel with refactoring capabilities

4) shortcut keys for the Edit function panel of the Alt+shift+s code

5) use more right-click and observe the shortcut keys for the actions you often use.

This introduction of the shortcut keys are the default configuration inside, but also tight is a few parts, more, better shortcut keys, you can go to experience.

Second, refactoring class shortcut keys

Multi-use refactoring can help us to change the code faster and reduce the probability of error.

1 Alt+shift+r Modify the variable, method name.

The most common thing we do during the encoding process is to modify the variable name. When a variable is used in many places in a Java class, it is cumbersome to modify, and if it is not refactored, it has to be modified one by another. If you use refactoring to modify a name, you only need to modify the operation once.

2 Refactoring Menu

1) Menu-->refactor

2) in the editing environment, right-click-->refactor (shortcut key alt+shift+t)

Third, configure Eclipse

Understanding this section can reduce our code input, improve efficiency, complete our classes faster, make it easier to write code, and write code more canonical.

1 Template Configuration

Now our most frequently used shortcut keys may be alt+/, or after entering a part of a word, let it pop up the helper code. And these are configured through templates, open menu: window-->preferences-->java-->editor-->templates

In the list on the right, you can see that a lot of templates have been provisioned for us in the system. When we write the code, we can see them as long as we use the shortcut keys alt+/in the blanks. such as: Sysout,systrace,main,test, there are many for,while,if templates. You can also add your own template to go in and reuse it. This is quite flexible.

Template for automatically generating annotations: In addition to the above template, there is actually a customizable template. is when you use shortcut keys (alt+shift+j) to generate Doc annotations for a class, eclipse is also generated through templates. If we change this template, we can create a completely personalized comment later.

Open Menu : window--> preferences--> java--> codestyle--> Code Template

One of the most commonly used functions, when adding comments to a class, the author's name, creation time, and other personalized information are written in.

For example: Open the Commentsàtypes on the right panel to modify its contents as:

/**

* xx System: <br>

* @author XXX <br>

* ${date} ${time}

* ${tags}

*/

When you add a comment to a class, you see the effect.

Or, when you fileànewàclass, under the new panel, there will be an option generate comments, selected. Open the new class and you'll see the effect.

2 Code Style Styles

When we use the shortcut key ctrl+shift+f , Eclipse will help us format the code, make the code more conform to the specification, and more orderly.

To Modify a style template :window-->preferences-->java-->codestyle--> formator--> The Edit button on the right panel.

Eclipse shortcuts and tips for use

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.