eclipse ~ shortcut key

A hardcore Eclipse developer summed up what he found to be the most useful but lesser-known shortcut key combinations. Through these combinations, it is easier to browse the source code, which improves the overall development efficiency and quality.
1. ctrl+shift+r: open 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 your workspace, and you only need to press the first few letters of the file name or mask name, such as applic*.xml. The fly in the ointment is that this set of shortcut keys does not work in all views.
2. ctrl+o: quick outline
If you want to view the method of the current class or a specific method, but you don't want to pull the code up and down, and don't want to use the search function, use ctrl+o. It can list all the methods and properties in the current class, you only need to enter the method name you want to query, and click enter to jump directly to the location you want to go to.

3. ctrl+e: Quick Transition Editor
This set of shortcut keys will help you navigate between open editors. Use ctrl+page down or ctrl+page up to browse the previous and next tabs, but with many files open, ctrl+e will be more efficient.

4. ctrl+2, L: Assign value to a local variable During the
development process, I often write a method first, such as Calendar.getInstance(), and then use the ctrl+2 shortcut key to assign the calculation result of the method to a local variable. This way I save time typing class names, variable names, and import declarations. The effect of Ctrl+F is similar, but the effect is to assign the result of the method calculation to the field in the class.
5. alt+shift+r: rename
Renaming properties and methods was a pain in the ass just a few years ago, requiring so much use of search and replace that the code became fragmented. Today's Java IDEs provide source code processing capabilities, as does Eclipse. Renaming variables and methods is now so easy, you'll get used to doing it 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 hit enter. That's it. If you are renaming a property in a class, you can click alt+shift+r twice, which will call up the source code processing dialog, which can automatically rename the get and set methods.
6. alt+shift+l and alt+shift+m: extracting local variables and methods
Source code processing also includes the ability to extract variables and methods from large blocks of code. For example, to create a constant from a string, select the text and press alt+shift+l. If the same string occurs elsewhere in the same class, it is automatically replaced. Method extraction is also a very handy feature. Breaking large methods into smaller, well-defined methods greatly reduces complexity and improves code testability.
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 + arrow keys
This is also a magic weapon to save time. This combination moves the content of the current line up or down. This shortcut works especially well in the try/catch section. 9. Everyone knows that
ctrl+m large display screen 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+. 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, that is, to modify the suggested shortcut keys. The modification suggestions in the new version of Eclipse are very good and can help you solve many problems, such as missing parameters in methods, throw/catch exceptions, unexecuted methods and so on.

More shortcut key combinations can be viewed in Eclipse by pressing ctrl+shift+L.
Let's take a look at some of my favorite hotkey combinations by frequency. (Note: The following content has been tested in Eclipse3.02 and above)
1. Control-Shift-T: Open type. If you don't intend to be a foreigner, forget the way to open it through the source tree. It is easy to open the implementation class of the interface with eclipse. Press ctrl+t to list the implementation class of the interface.
2. Control-Shift-R: Open resources (not just for finding Java files). Tip: Use the yellow double arrow button in the Navigator view to associate your edit window with the navigator. This will make the files you open appear correspondingly in the navigator's hierarchy, which makes it easy to organize information. If this affects speed, turn it off.
3. F3: Open declaration. Alternatively, use the Declaration Tab (in Java view mode, choose Windows --> Show View --> Declaration). When you select a method in the code and press this button, it will display the entire method in the declaration box.
4. Alt-left arrow: Go back in the Navigation History. Just like the back button of a web browser, it is especially useful after jumping with F3. (Used to return to the original compiled place)
5. Alt-right arrow: Navigate forward in the history.
6. Control-Q: Go back to the last edit. This shortcut is also used after 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 in the workspace. This is the premise of refactoring. For methods, this hotkey does the exact opposite of F3. It allows you to find all callers of a method up the method stack. A related function is to enable "occurrence marking". Select Windows->Preferences->Java->Editor->Mark Occurrences, check the option. At this point, when you click on an element, all the places in the code where the element exists will be highlighted. Personally I only use Mark Local Variables. Note: Too many highlights can slow down Eclipse.
8. Control-Shift-F: CodeàJavaàPreferencesàReformat 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, we open Eclipse, select Window Style, and set Code Formatter, Code Style and Organize Imports. Use the Export function to generate configuration files. We put these configuration files on the wiki, and then everyone on the team imported them into their own Eclipse.
9. Control-O: Quick outline. With this shortcut, you can quickly jump to a method or property, just by typing the first few letters of the name.
10. Control-/: Comment or uncomment a line. The same applies to multiple lines.
11. Control-Alt-down arrow: Copy the highlighted line or lines.
12. Alt-down arrow: Move one or more lines down. Alt-up arrow will move up.
Other hotkeys are available in the menu. You can see a list of all shortcuts by pressing Control-Shift-L (since version 3.1). Pressing Control-Shift-L twice brings up the Keys Preferences dialog, where you can set your own hotkeys. I welcome you to post your Eclipse tips in the Talkback section.
Other Eclipse Tips
I've summarized a few related tips:
Lock the command line window: In the command line view (Window ->Show View ->Other ->Basic ->Console), try locking the controls with the scroll lock button Do not scroll the console output.
Using the Ant View: In my Java or Debug mode, I like to show the Ant View so I can quickly run Ant tasks. This view can be found through Window Ant. Put the Ant view in the corner of the screen and add the build.xml file via the "Add à Other à Show View à Buildfiles" button. In version 3.1, the Ant debug scripting language is even supported.
Automatically iterate over a collection: for + Control-Space: If you don't know it yet, then you should remember that Control-Space is an autocomplete feature. In Eclipse, you can also autocomplete structures. Inside an array or collection, try typing "for" and pressing Control-Space. Eclipse will ask you which collection you want to iterate over and automatically complete the loop code.
Use hierarchical layout: I'm confused by the default layout (flat) in the Package Explorer view, which displays the full name of the package in the navigation tree. I prefer a package and filesystem view of my source, called Hierarchical Layout in Eclipse. To switch to this mode, click the down button in the package browser view, select Layout, then Hierarchial.
Show multiple files at once: You can browse multiple files at once. Drag an inactive edit window to the bottom or side scroll bar of the active window to open the edit window. This is the best way I can describe the trick.
Open two Eclipses at the same time: To merge changes from one CVS branch to the other, I like to do it by opening two different Eclipses at the same time in the Workspace. This way I can see all the changes by comparing the latest version on CVS (right click on the project and choose Compare Lastest from HEAD) and then merge each change into another CVS branch. The easiest way to launch multiple Eclipses is to use Eclipseàwith Launcher.
Implementors plugin: Installs a plugin that can jump to an implementation of an interface. If you're a dependency injection fan, or are working on well-written interfaces, then you need a plugin like this to speed up code navigation. You can find this plugin at SourceForge.
Ctrl+Alt+H
If you want to know which methods of a class are called by other classes, then please select the method name, then press "Ctrl+Alt+H",
Eclipse will show which methods are called by this method, Finally, a call relationship tree is generated. 1. Ctrl+left key
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, listing 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
to view the inheritance relationship tree of a class, which is top-down, press Ctrl+T again, it will change into a bottom-up display structure.
Tip: Select a method name and press Ctrl+T to view the parent class, subclass, and interface with the method with the same name.
Mnemonic: "T"------->"Tree"----->"Hierarchical tree"
4.Alt+left and right arrow keys
We often encounter Ctrl+left key when looking at the code, trace layer by layer, and then If you are lost in the code, you only need to press "Alt + left arrow key
" to return to the last reading position. Similarly, pressing "Alt + right arrow key" will advance to the reading position you just returned to, just like browsing The
forward and reverse buttons are the same for the controller.
Import Package: Ctrl+Shift+O Edit Scope Function Shortcut Global Find and Replace Ctrl+F Text Editor Find Previous Ctrl+Shift+K Text Editor Find Next Ctrl+K Global Undo Ctrl+Z Global Copy Ctrl+ C Global restore previous selection Alt+Shift+↓ Global cut Ctrl+X Global quick fix Ctrl1+1 Global content assist Alt+/Global selection all Ctrl+A Global delete Delete global context information Alt+? Alt+Shift+?Ctrl+Shift+Space Java editor shows tooltip description F2 Java editor selects encapsulated element Alt+Shift+↑ Java editor selects previous element Alt+Shift+← Java editor selects next element Alt+Shift+→Text editor Incremental Find Ctrl+J Text Editor Incremental Reverse Find Ctrl+Shift+J Global Paste Ctrl+V Global Redo Ctrl+Y View Scope Function Shortcuts Global Zoom In Ctrl+= Global Zoom Out Ctrl+-Window Scope Function Shortcuts Global Activate Editor F12 Global Toggle Editor Ctrl+Shift+W Global Previous Editor Ctrl+Shift+F6 Global Previous View Ctrl+Shift+F7 Global Previous Perspective Ctrl+Shift+F8 Global Next Editor Ctrl+F6 Global Next View Ctrl+F7 Global Next Perspective Ctrl+F8 Text Editor Show Ruler Context Menu Ctrl+W Global Show View Menu Ctrl+F10 Global Show System Menu Alt+- Navigation Scope Function Shortcut Java Editor Open Structure Ctrl +F3 Open Type Globally Ctrl+Shift+T Open Type Hierarchy Globally F4 Open Declaration Globally F3 Open External Javadoc Globally Shift+F2 Open Resource Globally Ctrl+Shift+R Global Back History Alt+← Global Forward History Alt+→Global Previous Ctrl+, global next Ctrl+. It is recommended to set it yourself. It can also be corrected automatically using Ctrl+1. Debug/Run Scope Function Shortcuts Global Single Step Back F7 Global Step Skip F6 Global Step Into F5 Global Step Into Select Ctrl+F5 Global Debug Last Start F11 Global Continue F8 Global Single Step Using Filter Shift+F5 Global add/remove breakpoints Ctrl+Shift+B Global display Ctrl+D Global run last start Ctrl+F11 Global run to line Ctrl+R Global execution Ctrl+U Refactoring scope function Shortcut keys Global undo refactoring Alt+Shift+Z Global Extract Method Alt+Shift+M Global Extract Local Variables Alt+Shift+L Global Inline Alt+Shift+I Global Move Alt+Shift+V Global Rename Alt+Shift+R Global Redo Alt+ Shift+Y
(1) Ctrl+M switches the size of the window (2) Ctrl+Q jumps to the last edit place (3) F2 When the mouse is placed on a marker and the Tooltip appears, press F2 and the Tooltip will be displayed when the mouse is removed. Show Tooltip
Description. F3 jumps to the place of declaration or definition. F5 single-step debugging into the function inside. F6 single-step debugging does not enter the function. If Kingsoft PowerWord 2006 is installed, the shortcut key of "word selection switch" should be changed to another. F7 returns to the caller from inside the function. F8 executes until the next breakpoint. (4) Ctrl+Pg~ For XML files, it is to switch the code and the icon window (5) Ctrl+Alt+I to see the relevant information of variables in the Java file (6) Ctrl+PgUp is to open the "Show List" drop-down box for the code window , in this drop-down box, there are recently opened files (7) Ctrl+/ is this kind of //~ comment in the code window. Ctrl+Shift+/ is this /*~*/ comment in the code window and <!--~--> in the JSP file window. (8) Alt+Shift+O (or click the Toggle Mark Occurrences button in the toolbar) When a mark is clicked, the mark in other
places highlighted in yellow, and a white square will appear on the right border of the window. Clicking this box will jump to this marker. (9) Right-click the left border of the window, that is, where the breakpoint is added, and select Show Line Numbers to add line numbers. (10) Ctrl+I Format Active Elements. Ctrl+Shift+F Format Document. (11) Ctrl+S saves the current file. Ctrl+Shift+S saves all unsaved files. (12) Ctrl+Shift+M (first place the cursor on the class name of the package to be imported) The function is to add an Import statement. The effect of Ctrl+Shift+O is that the missing Import statement is added, and the redundant Import statement is deleted. (13) Ctrl+Space prompts the content to be typed, that is, Content Assist. At this time, in the input method, Chinese(Simplified)IME-
The shortcut keys of Ime/Nonlme Toggle (for switching between English and other texts) are changed to other ones. Ctrl+Shift+Space prompts Context Information. (14) Double-click the left border of the window to add a breakpoint. (15) Ctrl+D deletes the current line.
Eclipse shortcut keys Ctrl+1 Quick fix (the most classic shortcut key, needless to say) Ctrl+D: Delete the current line Ctrl+Alt+↓ Copy the current line to the next line (copy increase) Ctrl+Alt+↑ Copy the current line Go to the previous line (copy and add)
Alt+↓ Interaction position between the current line and the next line (especially practical, you can save the need to cut and paste first) Alt+↑ The current line and the interactive position of the previous line (same as above) Alt+← Previous edited page Alt+→ Next edit page (of course for the above one)
Alt+Enter Display the properties of the currently selected resource (project, or file or file)
Shift+Enter Insert a blank line in the next line of the current line (this time The mouse can be anywhere in the current line, not necessarily the last) Shift+Ctrl+Enter inserts a blank line in the current line (the principle is the same as the above)
Ctrl+Q locates the last edited place Ctrl+L locates a line (for programs People who have more than 100 have good news) Ctrl+M maximizes the current Edit or View (press again and vice versa) Ctrl+/ Comments the current line, presses again to uncomment Ctrl+O Quickly displays OutLine Ctrl+T Quickly displays the inheritance of the current class Structure Ctrl+W Close the current Editor Ctrl+K Refer to the selected Word to quickly navigate to the next Ctrl+E Quickly display the drop-down list of the current Editor (if the current page is not displayed in bold)
Ctrl+/(Keyboard) Collapse the current class All codes
Ctrl+× (keyboard) Expand all codes in the current class
Ctrl+Space The code assistant completes some code insertion (but generally it conflicts with the input method, you can modify the hotkey of the input method, or you can temporarily use
Alt+/ instead)
Ctrl+Shift+E Displays and manages all currently opened Views Manager (can choose to close, activate, etc.)
Ctrl+J Forward incremental search (after pressing Ctrl+J, each letter editor you enter provides quick matching to locate a word, if not
, then It is displayed in the stutes line that it is not found. It is especially useful when looking up a word. Idea has this function two years ago.)
Ctrl+Shift+J Reverse incremental search (same as the previous one, but from back to front Check)
Ctrl+Shift+F4 Close all open editors
Ctrl+Shift+X Change all the currently selected text to lowercase
Ctrl+Shift+Y Change all the currently selected text to lowercase
Ctrl+Shift+F Format the current code
Ctrl+ Shift+P locates the matching character (such as {}) (when positioning from the front to the back, the cursor should be in the matching character, from the back to the front, and vice versa
)
The shortcut keys below are commonly used in reconstruction, and I like it myself And the commonly used ones are sorted out (note: the shortcut keys for general refactoring all start
with )
Alt+Shift+R Rename (it is my favorite one, especially the Rename of variables and classes, Saves a lot of labor than manual methods)
Alt+Shift+M Extraction method (this is one of the most common methods in refactoring, especially useful for a lot of muddy code)
Alt+Shift+C Modify the function structure (more practical, there are N functions that call this method, modify it once)
Alt+Shift+L Extract local variables (you can directly extract some magic numbers and strings into a variable, especially When calling multiple times)
Alt+Shift+F Change the local variable in the Class into a field variable (a more practical function)
Alt+Shift+I Merge variables (it may be a bit inappropriate to say Inline) Alt+Shift+V Move function And variable (not very commonly used) Alt+Shift+Z Refactoring regret medicine (Undo)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326431645&siteId=291194637