Common Eclipse shortcuts-also suitable for STS

Source: Internet
Author: User

A lot of content comes from the internet and known files, I only organize.

1. Ctrl+shift+r: Open Resource

这可能是所有快捷键组合中最省时间的了。这组快捷键可以让你打开你的工作区中任何一个文件,而你只需要按下文件名或mask名中的前几个字母,比如applic*.xml。美中不足的是这组快捷键并非在所有视图下都能用。

2. Ctrl+o: Fast Outline

如果想要查看当前类的方法或某个特定方法,但又不想把代码拉上拉下,也不想使用查找功能的话,就用ctrl+o吧。它可以列出当前类中的所有方法及属性,你只需输入你想要查询的方法名,点击enter就能够直接跳转至你想去的位置。

3. Ctrl+e: Quick Convert Editor

这组快捷键将帮助你在打开的各个开发模块(编辑器)之间浏览。使用ctrl+page down或ctrl+page up可以浏览前后的选项卡,但是在很多文件打开的状态下,ctrl+e会更加有效率。

4. Ctrl+2,l: Assigning a value to a local variable

开发过程中,我常常先编写方法,如Calendar.getInstance(),然后通过ctrl+2快捷键将方法的计算结果赋值于一个本地变量之上。 这样我节省了输入类名,变量名以及导入声明的时间。Ctrl+F的效果类似,不过效果是把方法的计算结果赋值于类中的域。

5. Alt+shift+r: Renaming

重命名属性及方法在几年前还是个很麻烦的事,需要大量使用搜索及替换,以至于代码变得零零散散的。今天的Java IDE提供源码处理功能,Eclipse也是一样。现在,变量和方法的重命名变得十分简单,你会习惯于在每次出现更好替代名称的时候都做一次重命名。要使 用这个功能,将鼠标移动至属性名或方法名上,按下alt+shift+r,输入新名称并点击回车。就此完成。如果你重命名的是类中的一个属性,你可以点击alt+shift+r两次,这会呼叫出源码处理对话框,可以实现get及set方法的自动重命名。

More shortcut key combinations can be viewed at Eclipse Press Ctrl+shift+l.

Use the frequency to see some hotkey combinations

  1. CONTROL-SHIFT-T: Opens type (open type). 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.

  3. F3: Opens the Declaration (open declaration). Alternatively, use 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 show the entire method in the Declaration box.

  4. Alt-left Arrow: Back in navigation history (Navigation). Just like a Web browser's Back button, it is especially useful after jumping with F3. (Used to return to the original compiled place)

  5. Alt-right Arrow: Navigates forward in history.

  6. Control-q: Go back to the last editing place. This shortcut is also used when you jump in the code. Especially when you're too deep, and forget what you were doing in the first place.

  7. CONTROL-SHIFT-G: Search for references in Workspace (reference). This is the premise of refactoring. For the method, the function of this hotkey is exactly the opposite of F3. It enables you to find all the callers of a method in the stack of methods. One function associated with this is to turn on the "tagging" feature (occurrence marking). Select windows->preferences->java-> editor-> Mark occurrences and tick the option. At this point, when you click on an element, all of the elements in the code where the element exists will be highlighted. I personally only use "Mark local variables" (Mark locally Variables). Note: Too much highlighting slows eclipse.

  8. Control-shift-f: Codeàjavaàpreferencesà reformat 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 the window Style, and then set the Code formatter,code style and organize Imports. Use the export feature to generate a configuration file. We put these profiles on the wiki, and everyone in the team is imported into their eclipse.

  9. Control-o: Fast Overview (Quick outline). With this shortcut, you can quickly jump to a method or property and just enter the first few letters of the name.

  10. control-/: Comments or uncomment a line. This is also true for multiple lines.

  11. Control-alt-down Arrow: Copies the highlighted row or rows.

  12. Alt-down Arrow: Moves one or more lines down. Alt-up Arrow will move up.

The other hotkeys are available in the menu. You can see a list of all the shortcut keys by pressing CONTROL-SHIFT-L (starting with version 3.1). Press Control-shift-l two times to display the Hotkey dialog (keys Preferences dialog), where you can set the hotkey yourself. I welcome your eclipse tips in the talkback section.

Other Eclipse Tips

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

Using Ant view: In my Java or debug mode, I like to show the ant view so I can run the ant task quickly. This view can be found through window ant. Place the ant view in the corner of the screen and add the Build.xml file with the add compiled file (addàotheràshow viewàbuildfiles) button. In version 3.1, even the Ant debug scripting language is supported.

Automatically traverse a collection: For + control-space: If you do not yet know, then you should remember that Control-space is the AutoComplete feature. In Eclipse, you can also automate the structure. In an array or collection range, try entering "for" and then pressing the Control-space key. Eclipse will ask you which collection you want to traverse and automatically complete the loop code.

Using hierarchical layouts: The default layout (flat) In Package Explorer View makes me confused, and it shows the full name of the package in the Navigation tree (navigation). I prefer the package and file system view of my source code, which is called the hierarchical layout (hierarchical layouts) in eclipse. To switch to this mode, click the Down button in the package browse view, select Layout, and then select Rating (hierarchial).

Show multiple files at once: You can browse multiple files at once. You can open an edit window that is not in the active state by dragging it to the bottom of the active window or to the scroll bar on the side. This is the best way I can describe the trick.

Open two eclipse simultaneously: to merge the changes from one CVS branch to another, I like to do this by opening two working directories (Workspace) to different eclipse. This way I can see all the changes by comparing the latest version on CVS (right-click the project and then select Compare lastest from HEAD) and then merge each change into another CVS branch. The simplest way to start multiple eclipse is to take advantage of Eclipseàwith Launcher.

Implementors plugin: Installs a plug-in that can jump to an implementation of an interface. If you're a dependency injection fan, or you're working on an excellent interface, you'll need a plugin like this to speed up code navigation. You can find this plugin in SourceForge.

Ctrl+alt+h

If you want to know how a class's methods are called by those other classes, check the name of the method 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 see the definition of variables, methods, classes

    1. Ctrl+o

View a schema for a class that lists its methods and member variables. Tip: If you press Ctrl+o again, you can list the methods and variables that the class inherits.

Help Note: "O", "Outline", "outline"

    1. Ctrl+t

Look at the inheritance tree of a class, which is top-down, and then press once more ctrl+t, which is replaced by a bottom-up display structure.

Tip: Select a method name and press Ctrl+t to see the parent, subclass, and interface of the method with the same name.

Mnemonic: "T" ——-> "tree"-–> "Hierarchy tree"

4.alt+ left and RIGHT ARROW keys

We often encounter when looking at the code CTRL + left, layer tracking, and then lost in the code, then only need to press "ALT + LEFT ARROW key

"You can go back to where you last read, and by the same token, press ALT + RIGHT ARROW to go to the reading position you just returned, like the browser's

Forward and Back buttons are the same.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Common Eclipse shortcuts-also suitable for STS

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.