Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What are the format shortcuts in Java?
What are the format shortcuts in Java?
Henan Xinhua has been focusing on Internet education for 32 years. Toll reimbursement free audition course! !

1.ctrl+shift+r: open the resource.

This is probably the most time-saving of all shortcut key combinations. This set of shortcut keys allows you to open any file in the workspace, just press the first few letters in the file name or mask name, such as applic*.xml. The fly in the ointment is that this set of shortcut keys cannot be used in all views.

2.ctrl+o: Quick Outline

If you want to see the methods of the current class or a specific method, but you don't want to drop down the code or use the search function, use CTRL+O, which can list all the methods and properties of the current class. You just need to enter the name of the method you want to query, and click Enter to jump directly to the location you want to go to.

3.ctrl+e: Quick Transformation Editor

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

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

In the process of development, I often write a method, such as Calendar.getInstance (), and then assign the calculation result of the method to a local variable through the shortcut key ctrl+2. This saves me the time to enter the class name, variable name and import declaration. Ctrl+F has a similar effect, but the effect is to assign the calculation result of the method to the field in the class.

5.alt+shift+r: rename

Renaming properties and methods was a troublesome thing a few years ago, which required a lot of searching and replacement, so that the code became fragmented. Today's Java IDE provides source code processing, and so does Eclipse. Now, renaming variables and methods is very simple, and you will get used to renaming them every time there is a better alternative name. To use this function, move the mouse to the property name or method name, press alt+shift+r, enter a new name, and then press Enter. That's it. If you rename an attribute in a class, you can click alt+shift+r twice, which will bring up the source code processing dialog box, and you can 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 function of extracting variables and methods from a large number of codes. For example, to create a constant from a string, simply select the text and press Alt+Shift+L. If the same string appears elsewhere in the same class, it will be automatically replaced. Method extraction is also a very convenient function. Breaking down large methods into smaller, well-defined methods will greatly reduce complexity and improve the testability of code.

7.shift+enter and ctrl+shift+enter

Shift+enter creates an empty line under the current line, regardless of whether the cursor is at the end of the line. Ctrl+shift+enter inserts an empty line before the current line.

8.Alt+ arrow keys

This is also a magic weapon to save time. This combination moves the contents of the current line up or down. This shortcut is particularly useful in the try/catch section.

9.ctrl+m

As we all know, a large display screen can improve work efficiency. Ctrl+m is a shortcut key to maximize the editor window.

10.ctrl+。 And ctrl+ 1: next error and quick fix.

Ctrl+。 Moves the cursor to the next error or warning in the current file. I usually use this set of shortcut keys together with ctrl+ 1, which is to modify the suggested shortcut keys. The modification suggestions of the new version of Eclipse are very good, which can help you solve many problems, such as missing parameters in methods, throwing/catching exceptions, methods not being executed, and so on.

Ctrl + Shift + O? : Import and manage import statements

Ctrl + Shift + T? : Open the open type lookup class file.

Ctrl + Shift + F4? : Close the open window.

Ctrl + O? : open statement

Ctrl + E? : Open the editor (switch window)

Ctrl + /? : Comment this line.

Alt + Shift + R? : Rename

Alt + Shift + L? : extract local variables

Alt + Shift + M? : extraction method

F3? : open statement

Ctrl+D: delete this line Ctrl+SHIFT+F: plastic.

Ctrl+Alt+↓(↑): copy this line Alt+↓(↑) down (up): move this line Alt+. Note: Personally, I think this shortcut key is the most useful. (1) In the java class, to output the main method, just enter main and press Enter with this shortcut key; To output System.out.println (), just enter syso and press enter with this shortcut key. For example, if you want to override the parent's toString () method, just type to and press enter with this shortcut key; For example, if you want to use a class that has not been imported (such as a calendar), you only need to enter Ca and then use this shortcut key to select it with the up and down keys; For example, if you want to generate a get, set method of a field, just enter get and use this shortcut key to generate it (public); Default); Another example is ... (2) You can use this prompt to enter a tag in a jsp page (tag attributes are prompted in the tag). (3) This shortcut key can also be used in xml.

Alt+shift+j adds a document comment to the function.

# Ctrl+Shift+O: import and manage the imports statement. After using FormatOnSave plug-in, it has not been used. It will be imported automatically when saving. # Ctrl+Shift+T: Open the open search class file # Ctrl+Shift+F4: Close the open window. Use CTRL+ w # ctrl+o: Open declarations # ctrl+e: open the editor (switching window) # Ctrl+/: pay attention to this line # alt+shift+r: rename # alt+shift+l: extract local variable # Alt+Shift+M: extraction method # F3: use ctrl+mouse for opendeclaration.

A menu will pop up after alt+shift+x,

Ctrl+shift+F will automatically adjust the format.