Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the keyboard shortcuts and other common functions commonly used in Eclipse

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail about the keyboard shortcuts and other commonly used functions in Eclipse. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

The 10 most useful shortcut key combinations in Eclipse

An Eclipse developer summed up what he thought were the most useful but lesser-known shortcut key combinations. Through these combinations, it is easier to browse the source code and improve the overall development efficiency and quality.

1. Ctrl+shift+r: open a resource

This is probably the most time-saving of all shortcut key combinations. This set of shortcuts allows you to open any file in your workspace by pressing the first few letters of the file name or mask name, such as applic*.xml. The only drawback is that this set of keyboard shortcuts does not work in all views.

2. Ctrl+o: fast outline

If you want to see the method of the current class or a particular method, but don't want to pull the code up and down, and don't want to use the lookup feature, use ctrl+o. It can list all the methods and properties in the current class, you just need to enter the name of the method you want to query, click enter and you can jump to the location you want to go directly.

3. Ctrl+e: quick conversion Editor

This set of keyboard shortcuts will help you navigate between open editors. Using ctrl+page down or ctrl+page up, you can browse the tabs before and after, but ctrl+e is more efficient when many files are open.

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

During development, I often write a method, such as Calendar.getInstance (), and then assign the evaluation of the method to a local variable through the ctrl+2 shortcut key. This saves me the time of typing class names, variable names, and import declarations. The effect of Ctrl+F is similar, but the effect is to assign the evaluation result of the method to the field in the class.

5. Alt+shift+r: rename

Renaming properties and methods was a hassle a few years ago, requiring so much search and replacement that the code became fragmented. Today's Java IDE provides source code processing, and so does Eclipse. Now, renaming variables and methods is so simple that you are used to renaming every time a better alternative name appears. To use this feature, move the mouse over the property or method name, press alt+shift+r, enter the new name, and click enter. It's done. If you rename an attribute in the class, you can click alt+shift+r twice, which will call out the source handling dialog box and automatically rename the get and set methods.

6. Alt+shift+l and alt+shift+m: extracting local variables and methods

Source processing also includes the ability to extract variables and methods from large chunks 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 class, it is automatically replaced. Method extraction is also a very convenient function. Decomposing large methods into smaller, fully defined methods greatly reduces complexity and improves the testability of the code.

7. Shift+enter and ctrl+shift+enter

Shift+enter creates a blank line below the current line, regardless of whether the cursor is at the end of the line. Ctrl+shift+enter inserts a blank line before the current line.

8. Alt+ key

This is also a time-saving magic weapon. This combination moves the contents of the current line up or down. This shortcut works especially well in the try/catch section.

9. Ctrl+m

It is well known that large display screens can improve work efficiency. Ctrl+m is the shortcut key for maximizing the editor window.

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

Ctrl+. Move the cursor to the next error or warning in the current file. I usually use this group of shortcuts with ctrl+1, that is, to modify the recommended shortcuts. The modification proposal for the new version of Eclipse does a good job and can help you solve many problems, such as missing parameters in methods, throw/catch exception, unexecuted methods, and so on.

More shortcut key combinations can be viewed by holding down ctrl+shift+L in Eclipse.

Let's take a look at some of my favorite hotkey combinations by frequency. (note: the following contents have passed the test in Eclipse3.02 and previous versions)

1. Control-Shift-T: open type (Open type). If you don't mean to dawdle, forget how to open it through the source tree (source tree). It is easy to open the implementation class of the interface with eclipse. Pressing ctrl+t will list the implementation class of the interface.

2. Control-Shift-R: open resources (not just to find Java files). Tip: use the yellow two-way arrow button in Navigator view to associate your editing window with the navigator. This will allow the files you open to be displayed in the navigator's hierarchy, making it easy to organize the information. If this affects the speed, turn it off.

3. F3: open statement (Open declaration). Alternatively, take advantage of Declaration Tab (in Java view mode, select Windows-- > Show View-- > Declaration). When you select a method in the code and press the button, it will display the entire method in the declaration box.

4. Alt-left arrow: step back in the navigation history (Navigation History). Like the back button in Web browsers, it is especially useful after using F3 to jump. (used to return to the place where it was compiled)

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

6. Control-Q: go back to where you last edited. This shortcut is also used when you jump in the code. Especially when you drill too deep and forget what you were doing in the first place.

7. Control-Shift-G: search for references (reference) in workspace. This is the premise of refactoring. For the method, this hotkey works just the opposite of F3. It allows you to find all the callers of a method up the method stack. A related function is to turn on the tagging function (occurrence marking). Select Windows- > Preferences- > Java- > Editor- > Mark Occurrences, and check the option. At this point, when you click an element, all the places in the code where the element exists are highlighted. Personally, I only use "marked local variables" (Mark Local Variables). Note: too many highlights will slow down the Eclipse.

8. Control-Shift-F: Code à Java à Preferences à reformat the code according to the code style setting. Our team has a uniform code format, and we put it on our wiki. To do this, we open Eclipse, select Window Style, and then set up Code Formatter,Code Style and Organize Imports. Use the export (Export) feature to generate configuration files. We put these configuration files on wiki, and everyone on the team imports them into their own Eclipse.

9. Control-O: quick summary (quick outline). With this shortcut, you can quickly jump to a method or property by entering only the first few letters of the name.

10. Control-/: comments or uncomments a line. The same applies to multiple lines.

11. Control-Alt-down arrow: copies one or more highlighted lines.

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

Other hotkeys are on the menu. You can see a list of all the shortcuts by pressing Control-Shift-L (starting with version 3.1). Press Control-Shift-L twice and the hotkey dialog box (Keys Preferences dialog) will be displayed, where you can set the hotkey yourself. You are welcome to post your Eclipse prompt in the Talkback section.

Other Eclipse tricks

I summed up a few related tips:

Lock the command line window: in the command line view (Window-> Show View-> Other-> Basic-> Console), try using the scroll lock button to lock the console output without scrolling.

Use the Ant view: in my Java or Debug mode, I like to display the Ant view so that I can run Ant tasks quickly. The view can be found 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, the Ant debugging scripting language is even supported.

Automatically traverse a collection: for + Control-Space: if you don't already know, then you should remember that Control-Space is an autocomplete function. In Eclipse, you can also automatically complete the structure. Within an array or collection, try typing "for" and then pressing the Control-Space key. Eclipse will ask you which collection you want to traverse and then automatically complete the loop code.

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

Show multiple files at a time: you can browse more than one file at a time. Drag an editing window that is not active to the scroll bar at the bottom or side of the active window to open the editing window. This is the best way I can describe the trick.

Open two Eclipse at the same time: to merge changes from one CVS branch to the other, I like to do this by opening two working directories (Workspace) different Eclipse at the same time. So I can see all the changes by comparing the latest version on CVS (right-click the project and select Compare Lastest from HEAD) and merge each change into another CVS branch. The easiest way to start multiple Eclipse is to take advantage of Eclipse with Launcher.

Implementors plug-in: installs a plug-in that can jump to an interface implementation. If you are a fan of dependency injection or are working on writing good interfaces, you need a plug-in to speed up code navigation. You can find this plugin at SourceForge.

Ctrl+Alt+H

If you want to know which methods of one class are called by those other classes, select the method name and press "Ctrl+Alt+H"

Eclipse will show which methods are called by this method, resulting in a call tree.

1. Ctrl+ left button

This is often 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 one more time to list the inherited methods and variables of this class.

Mnemonic: "O"-> "Outline"-> "outline"

3. Ctrl+T

Look at the inheritance tree of a class, which is top-down. Press Ctrl+T one more time and it will be replaced by a bottom-up display structure.

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

Mnemonic: t-> Tree-> hierarchical Tree

4.Alt+ left and right direction key

We often encounter the situation that when we look at the code, Ctrl+ the left button, track layer by layer, and then get lost in the code, we only need to press the "Alt+ left arrow key"

"you can go back to the position you read last time. By the same token, press the" Alt+ right arrow key "to enter the reading position you just returned before the meeting, just like the browser's

The forward and back buttons are the same.

Import package: Ctrl+Shift+O

Editing

Scope function shortcut key

Find and replace Ctrl+F globally

The text editor finds the previous Ctrl+Shift+K

Text editor to find the next Ctrl+K

Global undo Ctrl+Z

Global replication Ctrl+C

Global restore previous selection Alt+Shift+ ↓

Global cut Ctrl+X

Global fast correction Ctrl1+1

Global content assist Alt+/

Check Ctrl+An all globally

Delete Delete globally

Global context information Alt+?

Alt+Shift+?

Ctrl+Shift+Space

Java editor displays tooltip description F2

Java Editor Select Encapsulation element Alt+Shift+ ↑

The Java editor selects the previous element Alt+Shift+ ←

The Java editor selects the next element, Alt+Shift+ →

Text editor incremental lookup Ctrl+J

Text editor incremental reverse lookup Ctrl+Shift+J

Paste Ctrl+V globally

Global redo Ctrl+Y

View

Scope function shortcut key

Global magnification Ctrl+=

Global reduction of Ctrl+-

Window

Scope function shortcut key

Global Activation Editor F12

Global toggle Editor Ctrl+Shift+W

Global previous editor Ctrl+Shift+F6

Global previous view Ctrl+Shift+F7

Global last perspective Ctrl+Shift+F8

Global next editor Ctrl+F6

Global next view Ctrl+F7

Global next perspective Ctrl+F8

The text editor displays the ruler context menu Ctrl+W

Global display View menu Ctrl+F10

Global display system menu Alt+-

Navigation

Scope function shortcut key

The Java editor opens the structure Ctrl+F3

Global open type Ctrl+Shift+T

Open type hierarchy F4 globally

Global Open statement F3

Open external javadoc Shift+F2 globally

Open resource Ctrl+Shift+R globally

Global fallback history Alt+ ←

Global forward History Alt+ →

Last Ctrl+ globally

Global next Ctrl+.

Java Editor displays outline Ctrl+O

Open type Ctrl+Shift+H globally in the hierarchy

Go globally to matching parentheses Ctrl+Shift+P

Go globally to the previous editing location Ctrl+Q

The Java editor goes to the previous member Ctrl+Shift+ ↑

The Java editor goes to the next member Ctrl+Shift+ ↓

Text editor goes to line Ctrl+L

Search

Scope function shortcut key

Global appears in the file Ctrl+Shift+U

Open the search dialog box Ctrl+H globally

Declaration Ctrl+G in the global workspace

Reference Ctrl+Shift+G in the global workspace

Text editing

Scope function shortcut key

Text editor rewrite toggle Insert

Scroll Ctrl+ ↑ on the text editor

Scroll Ctrl+ ↓ under the text editor

File

Scope function shortcut key

Save Ctrl+X globally

Ctrl+S

Print Ctrl+P globally

Turn off Ctrl+F4 globally

Save Ctrl+Shift+S all globally

Turn off Ctrl+Shift+F4 all globally

Global property Alt+Enter

Create a new Ctrl+N globally

Project

Scope function shortcut key

Build Ctrl+B all globally

source code

Scope function shortcut key

Java editor formatting Ctrl+Shift+F

The Java editor uncomments Ctrl+/

Java Editor comment Ctrl+/

Java Editor to add a single import Ctrl+Shift+M

The Java editor organizes multiple import Ctrl+Shift+O

The Java editor uses try/catch blocks to surround the unset, which is too common, so it is listed here, and it is recommended to set it yourself.

You can also use Ctrl+1 for automatic correction.

Debug / run

Scope function shortcut key

Global step back to F7

Skip F6 in a global step

Step into F5 globally

Global step-in Select Ctrl+F5

Global debugging the last time F11 was started

Global continue F8

Step into Shift+F5 using a global filter

Globally add / remove breakpoint Ctrl+Shift+B

Global display Ctrl+D

Global run Last time Ctrl+F11 was started

Run globally to line Ctrl+R

Global execution of Ctrl+U

Reconstruct

Scope function shortcut key

Global undo refactoring Alt+Shift+Z

Global extraction method Alt+Shift+M

Global extraction of local variable Alt+Shift+L

Global inline Alt+Shift+I

Global Mobile Alt+Shift+V

Rename Alt+Shift+R globally

Global redo Alt+Shift+Y

(1) Ctrl+M toggle window size

(2) Ctrl+Q skips to the last editing office

(3) F2 when the mouse is placed on a mark and Tooltip appears, press F2 to move the mouse away, and the Tooltip will also display that is Show Tooltip.

Description .

F3 jumps to a declared or defined place.

F5 step debugging into the inside of the function.

F6 single-step debugging does not enter the interior of the function, if installed Kingsoft Ciba 2006, then change the shortcut key of "take word switch" to another.

F7 returns from the inside of the function to the call.

F8 executes until the next breakpoint.

(4) Ctrl+Pg~ is a switch code and graphic window for XML files.

(5) Ctrl+Alt+I looks at the relevant information of variables in Java file.

(6) Ctrl+PgUp opens the "Show List" drop-down box for the code window, where the recently opened file is displayed.

(7) Ctrl+/ is this kind of / / ~ comment in the code window.

Ctrl+Shift+/ is this kind of / * * / comment in the code window and

Share To

Internet Technology

© 2024 shulou.com SLNews company. All rights reserved.

12
Report