10 most useful shortcut keys for Eclipse (reposted to favorites) and eclipse shortcut keys

Source: Internet
Author: User

10 most useful shortcut keys for Eclipse (reposted to favorites) and eclipse shortcut keys

Connection: https://www.cnblogs.com/iamfy/archive/2012/07/11/2586869.html

10 most useful shortcut keys in EclipseAn Eclipse hardcore developer sums up the combinations of shortcut keys that he thinks are the most useful but not well-known. Through these combinations, you can easily browse the source code, improving the overall development efficiency and quality. 1. ctrl + shift + r: Open the resourceThis may be the most time-efficient combination of all shortcut keys. This set of shortcuts allows you to open any file in your workspace, and you only need to press the file name or the first few letters in the mask name, such as applic *. xml. The disadvantage is that this set of shortcut keys are not available in all views.

2. ctrl + o: Quick outline

If you want to view the method of the current class or a specific method, but do not want to pull the code down or use the search function, press ctrl + o. It lists all methods and attributes of the current class. You only need to enter the name of the method you want to query and click enter to directly jump to the desired location.

3. ctrl + e: Quick conversion Editor

This set of shortcut keys will help you browse between open editors. You can use ctrl + page down or ctrl + page up to browse the front and back tabs. However, ctrl + e is more efficient when many files are opened.

4. ctrl + 2, L: assign values to local variables

During development, I often write a method, such as Calendar. getInstance (), and then assign the calculation result of the method to a local variable by pressing ctrl + 2. In this way, the input class name, variable name, and import declaration time are saved. The effect of Ctrl + F is similar, but the effect is to assign the calculation result of the method to the domain in the class.

5. alt + shift + r: Rename

Renaming properties and methods was a hassle a few years ago and requires a lot of search and replacement, so that the Code became scattered. Today's Java IDE provides the source code processing function, as is Eclipse. Now, renaming variables and methods is very simple, and you will get used to renaming every time a better alternative name appears. To use this function, move the mouse over the attribute or method name, press alt + shift + r, enter a new name, and press Enter. This is done. If you Rename an attribute in the class, you can click alt + shift + r twice. This will call the source code processing dialog box and automatically rename the get and set methods.

6. alt + shift + l and alt + shift + m: extract local variables and Methods

Source code processing also includes the ability to extract variables and methods from large pieces of code. For example, to create a constant from a string, select the text and press alt + shift + l. If the same string appears elsewhere in the same category, it will be automatically replaced. Method extraction is also a very convenient function. Decomposing large methods into small and fully-defined methods will greatly reduce the complexity and improve the Code testability.

7. shift + enter and ctrl + shift + enter

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

8. Alt + direction keys

This is also a magic weapon to save time. This combination moves the content of the current row up or down. In the try/catch section, this shortcut is particularly useful.

9. ctrl + m

Large display screens can improve work efficiency. Ctrl + m is the shortcut key for maximizing the size of the editor window.

10. ctrl +. And ctrl + 1: Next error and quick Modification

Ctrl +. move the cursor to the next error or warning area in the current file. I usually use this set of shortcut keys together with ctrl + 1, that is, modify the recommended shortcut keys. The new version of Eclipse is well-developed and can help you solve many problems, such as missing parameters in methods, throw/catch exception, and unexecuted methods.

For more shortcut keys, press ctrl + shift + L in Eclipse.

Let's take a look at some of my favorite hotkey combinations based on their usage frequency. (Note: The following content has been tested in Eclipse3.02 and Version 1)

1. Control-Shift-T: Open type ).

If you are not interested in doing this, forget to open the source tree. Using eclipse, you can easily open the interface implementation class. pressing ctrl + t will list the interface implementation class list.

2. Control-Shift-R: Open resources (not just to find Java files ).

Tip: Use the yellow two-way arrow button in the Navigator view to associate your editing window with the Navigator. This will display the opened files in the hierarchy of the navigator to facilitate the organization of information. If this affects the speed, turn it off.

3. F3: Open declaration ).

Alternatively, use the Declaration Tab (in Java View mode, choose Windows --> Show View --> Declaration ). When you select a method in the Code and press this button, it will display the entire method in the statement box.

4. Alt-left arrow: Move back from the Navigation History.

Just like the back button of the Web browser, it is particularly useful after the F3 jump. (Used to return the original compilation location)

5. Alt-right arrow: forward in the navigation history.

6. Control-Q: Return to the last editing place.

This shortcut key is also used when you jump to the code. Especially when you drill too deep and forget what you did first.

7. Control-Shift-G: Search for reference in workspace ).

This is the premise of refactoring. For methods, this hot key works in the opposite way as F3. It allows you to locate all callers of a method in the method stack. One function related to this is to enable the "mark" function (occurrence marking ). Choose Windows> Preferences> Java> Editor> Mark Occurrences and select the option. When you click an element, all the elements in the Code are highlighted. I personally only use Mark Local Variables ). Note: too many highlights will slow down Eclipse.

8. Control-Shift-F: Code à Java à Preferences à re-format the Code according to the Code style settings.

Our team has a unified code format and we put it on our wiki. To do this, open Eclipse, select Window Style, and set Code Formatter, Code Style, and Organize Imports. Use the Export function to generate a configuration file. We put these configuration files on the wiki, and then everyone in the team imported them to their own Eclipse.

9. Control-O: quick outline ).

With this shortcut key, you can quickly jump to a method or attribute, just enter the first few letters of the name.

10. Control-/: Comments or uncomments a line. The same applies to multiple rows.

11. Control-Alt-down arrow: copy one or more highlighted rows.

12. Alt-down arrow: move one or more rows down. Alt-up arrow moves up.

Other hotkeys are available in the menu. You can press Control-Shift-L (from version 3.1) to view the list of all shortcut keys. Press Control-Shift-L twice to display the key dialog box (Keys Preferences diences). You can set the key here. You are welcome to post your Eclipse prompt in the Talkback section.

Other Eclipse tips

Lock the command line window:

In the command line View (Window-> Show View-> Other-> Basic-> Console), try to use the scroll lock button to lock the Console output and avoid scrolling.

Use the Ant View:

In my Java or Debug mode, I like to display the Ant view so that I can quickly run Ant tasks. You can find this view through Window Ant. Place the Ant View in the corner of the screen and Add the build. xml file through the "Add à Other à Show View à Buildfiles" button. In version 3.1, Ant debugging script language is even supported.

Automatically traverse a set:

For + Control-Space: if you do not know, you should remember that Control-Space is automatically completed. In Eclipse, you can also automatically complete the structure. In an array or set range, enter "for" and press the Control-Space key. Eclipse will ask you which collection you want to traverse and then automatically complete the loop code.

Hierarchical layout:

The default layout (flat layout) in the Package Explorer view puzzles me. It displays the full name of the Package in the navigation tree. I prefer the package and file system view of my source code. In Eclipse, it is called Hierarchical Layout ). To switch to this mode, click the down button in the package browsing view, select Layout, and then select Hierarchial ).

Multiple files are displayed at a time:

You can browse multiple files at a time. Drag the edit window that is not in the activation status to the scroll bar at the bottom or side of the activation window to open the edit window. This is the best way to describe this tip.

Open two Eclipse at the same time:

To merge changes from one CVS branch to another, I like to achieve this by opening two working directories (Workspace) at the same time in different Eclipse. In this way, I can view all the changes by comparing the latest version of CVS (right-clicking the project, and then selecting Compare Lastest from HEAD), and then merge each change to another CVS branch. The simplest way to start multiple Eclipse is to use Eclipse à with Launcher.

Implementors Plugin:

Install a plug-in that can jump to an interface. If you are a fan of dependency injection, or are working on the basis of writing excellent interfaces, you need a plug-in to accelerate code navigation. You can find this plug-in SourceForge.

Ctrl + Alt + H:

If you want to know whether a class method is called by other classes, select the method name and press Ctrl + Alt + H ", eclipse will display the methods called by this method, and ultimately generate a call relationship tree.
1. Ctrl + Left click

This is frequently used by most people to view the definitions of variables, methods, and classes.

2. Ctrl + O

View the outline of a class and list its methods and member variables. Tip: press Ctrl + O to list the methods and variables inherited by the class.

Note: "O" ---> "Outline" ---> "Outline"

3. Ctrl + T

View the inheritance tree of a class, which is top-down. If you press Ctrl + T one more time, the structure is displayed from bottom to top.

Tip: select a method name and press Ctrl + T. You can view the parent class, subclass, and interface of the method with the same name.

Note: "T" -------> "Tree" -----> "Hierarchy Tree"

4. Alt + left and right direction keys

We often encounter situations where we read the code by pressing Ctrl + left-click, trace them layer by layer, and then get lost in the Code. In this case, we only need to press "Alt + Left-direction key" to return to the last read position, similarly, pressing "Alt + right arrow key" will move forward to the returned reading position, just like the browser's

The forward and backward buttons are the same.

Import package: Ctrl + Shift + O

Edit

Shortcut for scope Function

Globally search and replace Ctrl + F

Search for the previous Ctrl + Shift + K in the text editor

Search for the Next Ctrl + K in the text editor

Globally undo Ctrl + Z

Global copy Ctrl + C

Select Alt + Shift + continue for global recovery.

Globally cut Ctrl + X

Global quick correction Ctrl1 + 1

Global content assist Alt +/

Globally select Ctrl +

Delete globally

Global context information Alt +?

Alt + Shift +?

Ctrl + Shift + Space

Java editor display tooltip description F2

Java editor selects the encapsulation element Alt + Shift + Transform

Java editor selects the previous element Alt + Shift + ↓

Select the next element Alt + Shift + →

Text Editor incremental search Ctrl + J

Text Editor incremental reverse lookup Ctrl + Shift + J

Globally paste Ctrl + V

Global redo Ctrl + Y

View

Shortcut for scope Function

Zoom in globally Ctrl + =

Ctrl +-

Window

Shortcut for scope Function

Global activation editor F12

Global switch editor Ctrl + Shift + W

Global editor Ctrl + Shift + F6

Global View Ctrl + Shift + F7

Global Perspective Ctrl + Shift + F8

The next global editor Ctrl + F6

Next Global View Ctrl + F7

Ctrl + F8

Text Editor display ruler context menu Ctrl + W

Global View menu Ctrl + F10

Global display of System Menu Alt +-

Navigation

Shortcut for scope Function

Open the structure Ctrl + F3 in the Java editor.

Global Open type Ctrl + Shift + T

Global Open Type hierarchy F4

Global open declaration F3

Open external javadoc Shift + F2 globally

Globally open resource Ctrl + Shift + R

Global rollback history Alt + rollback

Global forward history Alt + →

Ctrl +,

Ctrl +.

Java editor display outline Ctrl + O

Globally open the type Ctrl + Shift + H in the hierarchy

Globally move to matching parentheses Ctrl + Shift + P

Go global to the previous editing location Ctrl + Q

Go to the previous Member Ctrl + Shift + ← in the Java editor.

Go to the next member in the Java editor Ctrl + Shift + ←

Text Editor to Ctrl + L

Search

Shortcut for scope Function

Globally displayed in the file Ctrl + Shift + U

Global Search dialog box Ctrl + H

Declare Ctrl + G in the global Workspace

Reference Ctrl + Shift + G in the global Workspace

Text editing

Shortcut for scope Function

Text Editor rewrite switch Insert

Ctrl + ← on the text editor

Ctrl + ←

File

Shortcut for scope Function

Save Ctrl + X globally

Ctrl + S

Print Ctrl + P globally

Globally Disable Ctrl + F4

Globally save Ctrl + Shift + S

Globally Disable Ctrl + Shift + F4

Global attribute Alt + Enter

Globally create Ctrl + N

Project

Shortcut for scope Function

Global build Ctrl + B

Source code

Shortcut for scope Function

Java editor format Ctrl + Shift + F

Java editor uncomment Ctrl +/

Java editor comment Ctrl +/

Add a single import Ctrl + Shift + M in the Java Editor

The Java editor organizes multiple import Ctrl + Shift + O

The Java editor uses try/catch blocks to enclose unset ones, which is too common. Therefore, we recommend that you set them here. You can also use Ctrl + 1 for automatic correction.

Debug/run

Shortcut for scope Function

F7 is returned in one global step.

Skip F6 in one global step

Global One-Step Jump to F5

Global One-Step Jump-in and select Ctrl + F5

Global debugging last started F11

Continue F8 globally

Shift + F5 in one step using filters globally

Globally Add/remove breakpoints Ctrl + Shift + B

Global display Ctrl + D

Global run last started Ctrl + F11

Run Ctrl + R globally

Execute Ctrl + U globally

Reconstruction

Shortcut for scope Function

Global undo reconstruction Alt + Shift + Z

Global extraction method Alt + Shift + M

Global extraction of local variables Alt + Shift + L

Global inline Alt + Shift + I

Move Alt + Shift + V globally

Globally rename Alt + Shift + R

Global redo Alt + Shift + Y

(1) Ctrl + M switch window size

(2) Ctrl + Q jump to the last editing position

(3) F2: When you place the cursor on a tag and press F2 to move the mouse away, the Tooltip will display the Show Tooltip.

Description.

F3 jumps to the declaration or definition.

F5 debug the function in one step.

F6 single-step debugging does not enter the function. If Kingsoft 2006 is installed, you need to change the shortcut key of "word acquisition switch" to another one.

F7 is returned to the call place by the function.

F8 continues until the next breakpoint.

(4) Ctrl + Pg ~ For XML files, the code and graphical window are switched.

(5) Ctrl + Alt + I view the variable information in the Java File

(6) Ctrl + PgUp open the "Show List" drop-down box for the code window. The drop-down box displays files that have been opened recently.

(7) Ctrl +/in the code window //~ Annotations.

Ctrl + Shift +/This is the case in the code window /*~ */Comment. In the JSP file window, it is <〈! --~ --> --〉.

(8) Alt + Shift + O (or click the Toggle Mark Occurrences button in the toolbar) When you click a tag, Other

This area is highlighted in yellow, and a white square appears in the right border of the window. Clicking this square will jump to this area.

(9) Right-click the left border of the window and select Show Line Numbers where the breakpoint is added to add a row number.

(10) Ctrl + I Format the activated element Format Active Elements.

Ctrl + Shift + F Format the file Format Document.

(11) Ctrl + S Save the current file.

Ctrl + Shift + S save all unsaved files.

(12) Ctrl + Shift + M (place the cursor on the class name of the package to be imported first) is to add the Import Statement.

Ctrl + Shift + O is used to add missing Import statements and delete unnecessary Import statements.

(13) Ctrl + Space: The system prompts that the entered Content is Content Assist. In this case, enter the Chinese (Simplified) IME-

The Ime/Nonlme Toggle shortcut key (used to switch between English and other texts) is changed to another one.

Ctrl + Shift + Space the prompt message is Context Information.

(14) double-click the left border of the window to add a breakpoint.

(15) Ctrl + D Delete the current row.

Eclipse shortcut keys

Ctrl + 1 quick fix (the most classic shortcut, you don't need to talk about it)

Ctrl + D: Delete the current row

Ctrl + Alt + ↓ copy the current row to the next row (copy added)

Ctrl + Alt + ↓ copy the current row to the previous row (copy added)

Alt + ↓ interaction position between the current row and the following row (especially practical, you can save cutting and pasting)

Alt + ↑ interaction between the current row and the previous row (same as above)

Alt + ↓ previous edited page

Alt + → next edited page (of course for the above)

Alt + Enter display the properties of the currently selected resource (project, or file)

Shift + Enter insert empty rows in the next row of the current row (the mouse can be at any position of the current row, not necessarily the last row)

Shift + Ctrl + Enter insert blank lines in the current line (same principle)

Ctrl + Q locate the Last edited location

Ctrl + L locate in a line (for those with more than 100 programs, there will be good news)

Ctrl + M maximize the current Edit or View (then press it, and vice versa)

Ctrl +/comment out the current row, and then press it to cancel the comment

Ctrl + O quick OutLine display

Ctrl + T quickly display the inheritance structure of the current class

Ctrl + W disable the current Editer

Ctrl + K quickly locate to the next one by referencing the selected Word

Ctrl + E: Click it to quickly display the drop-down list of the current Editer (if the current page is not displayed, it is displayed in bold)

Ctrl +/(keypad) collapse all code in the current class

Ctrl + × (keypad) show all the code in the current class

Ctrl + Space Code assistant inserts some code (but it is usually in conflict with the input method, you can modify the Input key, or temporarily use

Alt +/to replace)

Ctrl + Shift + E display the managers that manage all Opened Views (you can choose to close or activate them)

Ctrl + J forward incremental search (after pressing Ctrl + J, each letter editor you enter provides a quick match to locate a word. If not, it is not found in stutes line. It is particularly useful when querying a word. This function was available two years ago)

Ctrl + Shift + J reverse incremental search (the same as the previous one, but only from the back to the front)

Ctrl + Shift + F4 close all open Editer

Ctrl + Shift + X change all selected text to lowercase

Ctrl + Shift + Y change all selected text to lowercase

Ctrl + Shift + F format the current Code

Ctrl + Shift + P locate the matched character (for example, {}) (when positioning from the front, the cursor must be inside the matched character, followed by the front, and vice versa

The following shortcut keys are commonly used in refactoring. I like them and want to sort them out frequently (note: the keys for refactoring generally start with Alt + Shift)

Alt + Shift + R Rename (one of my favorite ones, especially the Rename of variables and classes, which saves a lot of labor compared with manual methods)

Alt + Shift + M extraction method (this is one of the most common methods in refactoring, especially useful for a lot of mud code)

Alt + Shift + C modify the function structure (more practical. N functions call this method and modify it once)

Alt + Shift + L extract local variables (you can directly extract some magic numbers and strings into one variable, especially when multiple calls are performed)

Alt + Shift + F convert the local variable in the Class to the field variable (more practical)

Alt + Shift + I merge variables (this may be a bit inappropriate Inline)

Alt + Shift + V moving functions and variables (not commonly used)

Alt + Shift + Z restructured regret medicine (Undo)

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.