Drop the mouse and use the best eclipse shortcuts

Source: Internet
Author: User

Background: Eclipse, as a development tool that you often use, is proficient and can achieve a multiplier effect. The following article summarizes some of the frequently used shortcut keys, very convenient.

There are many articles about eclipse shortcut keys, but most of them are not detailed and are not illustrated. This article will introduce the real practical Eclipse shortcut keys, skilled can be used without the mouse, you can do programming development.

I also intend to write some of the knowledge points of eclipse related to a series, in addition to shortcut keys, can also be written "How to debug, set an exception breakpoint, debug mode expression evaluation", "refactoring", "Practical Eclipse Operation Skills" and some other topics, so just learn Java friends, You can use eclipse in a more comprehensive way.

The more shortcuts you use, the more efficient your operation, and the more efficient your development will be, while it allows you to focus more on your code, rather than always letting your mouse divide your God.

This article just lists some of the commonly used Eclipse shortcut keys, and will add some handy shortcuts in succession.

1 Common shortcuts First: three ways to switch files 1, Ctrl + E, on the right to display all the files currently open.

2, Ctrl + PG UP, Ctrl + PG Dn, file hopping one by one.

Press CTRL + Pg Dn, jump from Adconf.java to Adquaryserviceimpl.java

Before:

After:

Vice versa.

3.Ctrl + F6 to display all files currently open in the current file

I personally prefer Ctrl + E this way.

Second trick: Copy the current line or the currently selected code block

In eclipse, if you need to copy a row without using CTRL + C, you only need to use CTRL + Alt +↓. Note that this shortcut key is usually conflicting and can be modified on the keys panel itself. I prefer to use CTRL + ALT + END to replace CTRL + Alt +↓.

Public class teststring {

public static void Main (string[] args) {

String s = "";

System. out . println (s = = null);

}

}

If you want to copy the "String s =" "line, simply position the focus to the row it corresponds to, and then press CTRL + ALT +↓. This shortcut also supports copying blocks of code.

Third trick: Show all properties and methods of the current class

Previously used in Eclipse's outline, you can now turn it off, because you can display all the properties and methods of the current file using CTRL + O. Note The capital letter O, not the number 0.

Four strokes: Ctrl + W Close the current file, CTRL + Shift + W Close all files Five strokes: Quickly locate the location of the current file in the project, that is, the location in the package view

One way is to directly click on "Link with Editor" in the package view.

However, there is a drawback to this approach, which is to use the mouse to click on "Link with Editor".

The second way is to use ALT + Shift +w, display the view, and then select the package view, and you can also navigate to the location of the current file in the package view, thus avoiding the use of the mouse.

Six strokes: Check the contents of the Java file

public string Get (@RequestParam (value = "key") string key) {

Object obj = oscacheservice.get (key);

If (obj! = null) {

Return Jsonutil. ToJson(obj);

}

return "";

}

If you position the mouse on the Oscacheservice, you can use ALT + Shift +→ to select Oscacheservice the entire string without using the mouse to manipulate it.

This shortcut is very handy, and if you want to select everything in the IF statement, you can use this shortcut, and so on.

It is convenient to select the contents of a block of statements, or

seventh trick: Ctrl +shift+ T select Java file, CTRL +shift+ R Select Resource File

1. control-shift-t: opens type (opentype). If you don't intentionally skiving, forget to open it through the source tree. Using Eclipse to easily open an implementation class for an interface, press CTRL+T to list the implementation class of the interface

2. control-shift-r: Open Resources (not just for Java files). tip: Use the yellow two-headed arrow button in the Navigator view to associate your editing window with the navigator. This allows you to open files that correspond to the hierarchy of the Navigator, which makes it easier to organize information. If this affects speed, turn it off.

Ctrl+t

Ctrl+t is to find the implementation class directly from the interface, which can be judged based on the text currently in the cursor. If the implementation class is found directly on an interface class name, the implementation method is directly found on an interface method.

Eighth trick: Ctrl + H for global search and local search

    1. Other than "File Search," You can remove from the view

      After using CTRL + H to bring up the search view, click Customize.

      Only the "File Search" option is retained, and the other options are not very useful.

    2. Local Search

      You can select from the view

      Perform a local search to improve efficiency.

The Nineth recruit automatically generates Get/set method, tostring method, hash method

    1. Use ALT + Shift +s to bring up code generation views

    2. After the view is paged out, the direct input R brings up the Get/set generation view, enter H to call out the hash method to generate the view, enter S to bring up the ToString Method generation view

Tenth strokes View Toggle Ctrl + F7

This shortcut is also quite useful, for example in code view, you want to see the contents of the console, Ctrl + F7 can help you.

For example, if you want to start Tomcat, just press CTRL + F7, switch to the Servers view, and then press CTRL + ALT + D to completely eliminate the need to use the mouse.

The 11th Trick Classic Quick Access

By entering CTRL + 3, you can use quick access. For example, if you want to configure the MAVEN environment for Eclipse, you usually need to click Windowàpreferencesàmaven, and with quick Access, you just need to enter MAVEN directly.

    1. Use CTRL + 3
    2. Enter the keywords you need to find in eclipse

12th strokes The jump between the variable name and the method

When you want to know which way the next method of the current method is, just press CTRL + Shift +↓ to achieve the goal, and this shortcut also applies to the variable name.

13th Strokes reconstruction

    1. Modify Name

      Suppose you want to modify a method's parameter name, or class variable, method variable, and these variables are referenced by a lot of code, then you can use ALT + Shift + R to unify the modification once.

      Focus on the variable name, then use ALT + Shift + R, at which time eclipse will prompt you to enter a new variable name, click Enter to modify the success. This shortcut key also applies to modifying the class name and method name.

    2. Extracting class methods

      If the code for a method is too long and you want to extract the sub-method, simply select a block of code and then use ALT + Shift + M to eject the view and enter the method name.

14th strokes Eclipse's breadcrumb function ALT + Shift + B

Eclipse's breadcrumb functionality is similar to the Package view feature, where you can display breadcrumbs in eclipse by simply pressing ALT + Shift + B.

Skilled use of this tool, you do not need the package view, the direct use of bread crumbs navigation function can be. Here by the way, how to copy the first name of a class.

    1. In the face class file, use ALT + Shift + B to bring up eclipse breadcrumbs
    2. Then click Enter and eclipse will automatically check the name of the class.

Some friends don't like this feature, so you can remove the breadcrumbs by clicking the Toggle breadcrumb button in the toolbar in eclipse.

15th Strokes Ctrl + Shift +g to find all classes that call a method

Sometimes you want to see which class methods are called by a Java method, and you can use CTRL + Shif + G directly.

To Getadorderbyid This method for example, the mouse navigates to this method, using CTRL + Shif + G.

All classes that call the Getadorderbyid method are listed on the search view

16th strokes Ctrl + K and CTRL + Shfit + K, find text

When you select certain strings in a file, you can use CTRL + K to look down the same string and use CTRL + Shfit +k to look up the same string.

17th Strokes Ctrl + F to bring up a view of the search text

On this view, there are options for filtering information, for example, case sensitive.

This view so many options, how to avoid using the mouse to click on it. A careful friend should be able to see that there is an underscore in the text of each option, such as:

, the letter C is underlined below, this time, you just need to use the ALT key to select, for example, Alt +c can select the "Case sensivive" option.

Another way to do this is to use the TAB key, which is not pressed once to select an option.

18th strokes How to close an open view without a mouse

If you open a view, such as Ctrl + F,ctrl + H, after you open the search view, you want to close it. You can use the ESC key directly to avoid using the mouse.

The 19th recruit review, after the code modification, want to start Tomcat, with shortcut keys how to operate

    1. Switch to servers view using CTRL + F7
    2. Use CTRL + Alt + D to start Tomcat.

20th trick how to quickly generate a for loop, switch, and other blocks of code

For example, if you want to write a switch code block, just type switch and then use ALT +/,eclipse to generate the following code:

Note In comparing the new Eclipse version, Alt +/is the default code hint shortcut, and the default shortcut for the older version is CTRL + Space, which conflicts with the input. How do I change the CTRL + Space default shortcut key?

Note that using the preceding knowledge points , you can use the shortcut keys to manipulate.

    1. Ctrl + 3
    2. Enter keys to jump to the keys view

    3. When you jump to the keys view, the option that is selected by default is, how to jump to, and then enter the content. You can use the tag key.

      Then enter content Assist,

    4. Using ALT + B, skip to the binding option and enter alt+/.
    5. Use the tag key to jump to the OK option and click Enter to take effect

21st Trick Close File

Use CTRL + W to close the current file, CTRL + Shift +w to close all files that are currently open.

If I close my current file, I regret it and want to open it again. You can use Alt +←.

22nd Strokes Case Conversion

CTRL + SHIFT + Y changes to lowercase, CTRL + SHIFT + X to uppercase.

23rd strokes Create various types of files

For example, to create a new class in the same package as the current file, you can use ALT + Shift + N to bring up the CREATE view and select the relevant type.

If you want to create it in any directory, use CTRL + N.

24th Strokes Delete the forward

Use CTRL + D, very useful shortcut keys

25th Strokes Find the closing brace according to the opening curly brace

When you press CTRL + Shift + p, you jump to the closing curly brace.

26th trick, how to jump from other views to the Code Editor view F12

Of course you can switch the view with the CTRL + F7 mentioned above, but if you switch to the Code Editor view, press F12 directly.

27th Trick How to jump to a specific line in a file, Ctrl + L

Ctrl + L, then enter the number of lines.

Drop the mouse and use the best eclipse shortcuts

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.