Eclipse utility operations that improve development efficiency

Source: Internet
Author: User
Tags list of attributes

工欲善其事, its prerequisite. For programmers, Eclipse is a "device". This article will cover the two chapters of Eclipse shortcuts and practical tips. Eclipse shortcut key after cooked, without the mouse, it can be programmed to develop, to avoid the mouse to divide your God. While mastering some of Eclipse's practical skills, you can greatly improve your development efficiency.

1, lose the mouse bar of the Eclipse shortcut 1.1 file switching three ways 1.1.1 Ctrl + E, on the right to display all the files currently open

1.1.2 Ctrl + PG UP, Ctrl + PG Dn, file hopping

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

Before:

After:

Vice versa.

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

I personally prefer Ctrl + E this way.

1.2 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 replace CTRL +alt +↓ with CTRL + ALT + END.

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.

1.3 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.

1.4 Ctrl + W close the current file, CTRL + Shift + W close all Files

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

1.5 Quickly locate the location of the current file in the project, which 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.

1.6 Select 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.

1.7 Ctrl + T Select a Java file, CTRL + R Select a resource file

If you're just looking for a Java class, it's more efficient to use CTRL + T directly.

1.8 Ctrl + H for global search and local search

1, in addition to "FileSearch", other can be removed 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. Partial Search

You can select from the view

Perform a local search to improve efficiency.

1.9 Automatic generation of Get/set method, tostring method, hash method

1. Use ALT + Shift+s to bring up the Code generation view

2, after the view, the direct input R call Get/set generation view, Input H call hash method to generate the view, enter S to bring up the ToString method to generate the view

2.0 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.

2.1 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

2.2 Jumps between variable names and methods

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.

2.3 Refactoring

1. Change the 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. Method of extracting class

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.

2.4 Eclipse bread crumbs 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 bread crumbs

2, then click Enter, 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.

2.5 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

2.6 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.

2.7 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.

2.8 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.

2.9 Review, after the code modified, 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.

3.0 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. After jumping to the keys view, the default selected option is, how to jump to, so as to enter content. You can use the tag key.

Then enter content Assist,

4, use ALT + B, jump to the binding option, enter alt+/.

5, use the tag key, jump to OK option, click Enter to take effect

3.1 Case Conversion

CTRL + Shift + Y to lowercase, ctrl +shift + x to uppercase.

3.2 Creating 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.

3.3 Delete When moving forward

Use CTRL + D, which is useful for shortcut keys.

3.4 Find closing brace according to opening curly brace


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

3.5 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.

3.6 How to jump to a specific line in a file, Ctrl + L

Ctrl + L, then enter the number of lines.

3.7 Automatically generate return values


Createsearchconditionoptions () What is the return value of this method? You can use CTRL + 1 to bring up the secondary view.

Then select Assign statement to new local variable. Eclipse will automatically generate a return value. This is a very practical operation, basically used every day. Of course you can also use the ctrl+2,eclipse directly in the lower right corner to pop up a secondary window, and then enter the letter L.

3.8 Display the Eclipse shortcut key list

Direct Input CTRL + SHIFT + L,eclipse will pop up the list of shortcuts in the lower right corner.

3.9 Displaying all attributes of HTML and XML elements

This is also a fairly useful shortcut key.

If I want to see what properties are available for an INPUT element, you can use the ctrl+shift+ comma to show the list of attributes.

The Eclipse shortcut key chapter is complete.

2. Eclipse Practical Tips 2.1 using the bookmark record code point

When you are reading other people's code, you can record the important logic of the code in the form of a bookmark to facilitate future queries.

If you want to record 132 lines, you can use the right mouse button, click "Add bookmark", write a bookmark.

After giving the bookmark a handy name, you can bring up the bookmark view to see the code point just recorded.

2.2 Bring up the various views of eclipse

For example, to bring up the bookmark view, you can do the following:

Window--ShowView--and other

So eclipse displays a view of Show view, then enters the bookmark, displays the "Bookmarks" entry, and clicks on it.

2.3 Console with too long content output to file

In general, if the console output in eclipse is too long, you can't see everything, and it's not easy to search for content, so you can export the content to a file for viewing.

Assuming the above code output is too long, you can specify the output file in the common option. Select Run configurations in the current class file

Then, when you run the code, the content is output to Test.log.

2.4 Using the working set working sets to categorize the project

There are often a lot of projects in an Eclipse workspace that are confusing. You can use working sets to categorize project at this time.

Such as:

For example, I put an ad system project into a ADSP work set. Put the admin field code in the admin working set. To do this, the first step is to designate "Top level Elements" as "working sets" and then click on "Configure working sets" to create the working set.

2.5 View Delimited

Sometimes when displaying JSP data, the field name of the domain model is used, so you can display the domain model and JSP page in two views, which is convenient for copy.

What if the Appaccess.java is shown below? You only need to drag Appaccess.java. When the upper and lower dividers appear, release the mouse.

2.6 Setting shortcut keys for Eclipse plug-ins

After you install an Eclipse plugin, you can set up a shortcut key for it. For example, if you install a vim plugin, the vim icon appears in the Eclipse Tools class.

After you press ctrl+shift+numpad_subtract, you can invoke the Vim plugin.

2.7 The character encoding of the unified Eclipse workspace

2.8 Changing the font size

Eclipse is also covered with the Operation chapter. I hope that through this article, you can more skilled use of eclipse.

Eclipse utility operations that improve development efficiency

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.