Summary of the most common Eclipse shortcuts (1)

Source: Internet
Author: User

Summary of the most common Eclipse shortcuts (1)

1. ctrl + shift + r: Open the resource

This 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 use the source tree to open it. 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 only 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 to select Windows> Show View> Declaration in Java View mode ). 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: returns the value 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 navigation history.

6.Control-Q: Return to the Last edited 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 "tag" 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" 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. The hotkey dialog box Keys Preferences diences is displayed. You can set the hotkey here. You are welcome to post your Eclipse prompt in the Talkback section.

Other Eclipse tips

I have summarized several tips:

Lock 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 do not scroll the screen.

Use 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 by clicking the "Add a compilation file" 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: In the Package Explorer view, the default layout is flat.) The full name of the Package is displayed in the navigation tree. I prefer my source package and file system view, which is called Hierarchical Layout in Eclipse ). To switch to this mode, click the down button in the package browsing view and select Layout), and then select hierarchical 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: To merge changes from one CVS branch to another, I like to open two working directories at the same time. Workspace) Different Eclipse implementation. In this way, you can view all the changes in the latest version of CVS, right-click the project, and select Compare Lastest from HEAD), and 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 to the returned reading position, just like the browser's forward and backward buttons.

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 +-


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.