IntelliJ IDEA navigation feature Top20

Source: Internet
Author: User

IntelliJ IDEA navigation feature Top20

In the previous article, I introduced the features related to Code Completion and refactoring in IntelliJ IDEA (IntelliJ. Today I will introduce another powerful tool, IntelliJ's Navigation, which will save you a lot of time if used properly.

As a user of IntelliJ, you should first make it clear that IntelliJ is a tool that lets you focus on code. Only in this way can we make full use of and enjoy its magic. Therefore, you should focus on the code editor most of the time and use navigation as a good helper for fast switching between codes in different locations.

This article aims to introduce the features of IntelliJ navigation on UI elements such as project files, block of code, tool window, and editor labels.

1. recently edited files

If you stop and carefully analyze all your Navigation patterns, you will realize that you only work on fixed files most of the time. This explains whyRecent filesIs a common feature of IntelliJ idea users. Once you are familiar with it, you will gradually introduce it into most of your navigation operations. To use this feature, you only need to use shortcuts.Ctrl + E(OS X isCmd + E).

Note that this function selects the last accessed document by default, so you only need to press ENTER or mouse to jump to this file. To reduce the number of candidate items in the list, you can useSpeed SearchFunction -- enter a part of the target file name. Only matching items are displayed in the list.

2. Structure popup)

What you do every day is to run around in the currently opened files, which share a common feature: they have their own file structure. For example, a Java class file contains a structure composed of fields and elements. XML and HTML files contain a tags tree structure. If you want to quickly navigate to a part of the file structure, press Ctrl + F12 (OS X isCmd + F12. (Similarly,Speed SearchCan also be used to reduce candidate items in the list)

Sometimes your requirements for information may affectStructure popup. For example, the structure diagram of a Java class may contain the structure information of the base class or Interface related to it. However, by default, IntelliJ idea hides them. If necessary, press the shortcut key again.

IntelliJ will record yourStructure popupAnd the next call to it.

3. Jump to the navigation bar

Generally, it is a pleasure to display only the editor with code on the screen. However, some people want to see the project tree because it helps to understand or quickly modify the context of the project. In practice, switching between the project tree and the editor is extremely easy in IntelliJ idea. But in fact, the project tree is not the best choice. Sophisticated IntelliJ users know a better alternative: navigation bar. New users often think that is just a breadcrumb, but in the eyes of experienced developers, This is a Swiss Army knife! Press the shortcut key Alt + Home (OS X is Alt +) ExecutionJump to navigation barWe can feel the power of it. With it, we can jump to every place of the project and create and modify any file and many other meaningful things.

It is worth mentioning that this operation can be performed even when the navigation bar is hidden.

4. Jump to a specified class

You may think:Go to a classWhat can I say about such a simple operation? Maybe you already know that Ctrl + N (OS X isCmd + N) Can jump between classes, but you may not know that this function is much more powerful than it looks. Besides simple wildcards, camper naming, and package name prefixes supported by various ides, IntelliJ can also match the intermediate name (middle name matching), line number suffix, quick document, definition menu (definition popups) and other methods to introduce this function:

By default,Go to a classFunction search is only executed in your project. If no matching item exists, click the shortcut key to expand the search in the library referenced by the project.

In IntelliJ, you can easily perform inter-class jump without using the mouse: When the menu appears, enter or modify the query statement, and then use the keyboard's upper and lower keys to select the target. If you have tried this method in other ides, you must know what I'm talking about.

5. Jump to the specified file or directory

When you need to open a specific file in the project, using the shortcut key Ctrl + Shift + N (Cmd + Shift + N in OS X) is the best choice. In addition to the basic functions, you can also search by wildcards, hump naming, and directory name prefixes.

6. Jump to the specified symbol

Finally I want to introduceGo...The last important member in the feature family --Go to a symbol. By pressing Ctrl + Shift + Alt + N (OS X is Cmd + Shift + Alt + N), full-text search is not needed) to the specified symbol. Because IntelliJ maintains indexes of all symbols in the project and library, no matter how large the project is, it can still easily find matching methods or fields in seconds through corresponding expressions.

7... Selected

In a specific tool window (such as Project/Changes View, or evenExplorer/FinderSelect the file being edited, and use the shortcut key Alt + F1.Select in...Is no longer convenient.

8. Switch to the specified tool window.

A simple shortcut key combination is assigned to most tool windows of IntelliJ idea. With the shortcut key, you can quickly call out the corresponding tool window and make it focus. When you press the shortcut key again when getting the focus in the tool window, the tool window will be hidden and you will be able to return to the editor for work. This method is easy to use. More importantly, it completely frees you from the mouse-Press the shortcut key whenever you need a specific tool window or want to return to the editor.

Make sure you can remember at least the following shortcut keys:

  • Project tool window: Alt + 1 (iN OS XCmd + 1)
  • Changes tool window: Alt + 9 (iN OS XCmd + 9)
  • Terminal tool window: Alt + F12
9. Return to the editor

Many people do not know a tip of IntelliJ idea-press Escape to return to the editor. When you use this method, the previously called tool window remains visible. Of course, if you don't want to see these windows, press the shortcut key.Ctrl + Alt + F12(OS X isCmd + Alt + F12.

(Note: The shortcut key corresponds to File Path during local testing, while Shift + F12 is the correct shortcut key)

10. Jump to the associated unit test

What are the common navigation functions when you are writing code, especially to ensure that the Code is satisfactory? Of course, it is switching back and forth in the class and the corresponding unit test. IntelliJ can identify the tests associated with each class and provideGo to a test. PressCtrl + Shift + T(OS X isCmd + Shift + T), You can freely move between them:

If there is no associated test for the class using this function, IntelliJ will help you generate one.

11. Skip to the top level

Another common behavior is that you want to browse the hierarchy of a class or its methods. In most ides, you can see an icon appear in a gutter in the same line as the method definition ). Click this icon to navigate to the location defined by this method in the parent class (or interface. In addition, IntelliJ's original name isSuper MethodPress the shortcut key Ctrl + U (OS X isCmd + U. It jumps up to a level without the help of the mouse.

12. Jump to the lower level

Why can't I jump up? Even so, in fact, few ides have implemented this function. Fortunately, IntelliJ is one of them. In addition to the parent class icon, IntelliJ also provides an icon that can be imported to the definition position of the method corresponding to the subclass. Therefore, in the IntelliJ world, it can be described as "up and down) omnipotent.

If you want to navigate to the lower layer faster without a mouse, use the shortcut key Ctrl + Alt + B (OS x is Cmd + Alt + B for OS X) to callImplementationsIt will list all subclasses that implement the current class for you to select:

13. Method hierarchy chart

What if I want to view the structure of all classes that implement or override the current method? In IntelliJ, there isMethod HierarchyYou can use the shortcut keyCtrl + Shift + H(OS X isCmd + Shift + H. This feature allows you to navigate to all classes that match this relationship:

14. dimo-popup)

We just learned some ways to navigate in the hierarchical structure of the method definition. In some cases, you may need to use navigation in the hierarchy of the current class (or the class where the cursor is located, no matter how many methods it has. Most ides achieve this by providing a hierarchical structure of a single class or interface. In IntelliJ, this function is called a type level (Type Hierarchy), The shortcut key isCtrl + H.

As you can see, this function returns a tree structure. Some may find this format hard to understand, so IntelliJ also provides anotherDimo-popup --The shortcut key isCtrl + Alt + U(OS X isCmd + Alt + U) -- Replaces the tree structure with a UML diagram to describe the hierarchical structure of the given class:

You don't need to be reminded to know that we can use it to navigate to any class or interface represented by graphics.

15. method call hierarchy

In addition to the hierarchy of classes and methods, we also have a special navigation behavior: navigation in the hierarchy of method calls. Each method calls many methods that call other methods, and so on. This is why you sometimes need to navigate to the method called or called by the current method. Shortcut KeyCtrl + Alt + HTo helpCall HierarchyFunction to allow IntelliJ idea to quickly present the calling hierarchy of the current method:

16. Display usage

It is also common to navigate to a position with the symbol specified by the cursor. To achieve this, each IDE providesFind usages. However, the disadvantage of this function is that it is usually very cumbersome-It not only needs to start a long running process, but also needs to create a tool window to display the results. Therefore, IntelliJ provides a lightweight solution --Show usagesThe shortcut key is Alt + Ctrl + F7 (OS X isCmd + Alt + F7):

 

This function displays results in the form of menus, and is only at the project level by default (ProjectLevel. If you call this function again, its running range will be extended to the project and library level (Project and librariesLevel ).

17. recently edited files

In the previous section, I introduced how to navigate to the recently accessed file. What if I want to filter files that have been recently edited? In IntelliJ, you only need to use the shortcut keyCtrl + Shift + E(In OS XCmd + Shift + E) CallRecently Edited FilesFunctions can easily meet this requirement:

18. navigation between views and controllers

Do you think it is enough for an IDE To understand only the most basic relationships in the project files (such as the class hierarchy, test coverage, usage, etc? What are the special relationships? PressCtrl + Alt + Home(OS X isCmd + Alt + HomeWith the help of IntelliJ IDEA.Related symbolAnd you can get the navigation function based on these special relationships (such as between views and controllers of Sping MVC, Grails, and even JavaFX applications.

19. Navigate to View controller)

Since IntelliJ idea can find out some special relationships in the project, what special navigation functions does it have? If you are a Web App developer, you can callGo to a symbolFunction to quickly find it:

20. Database-related Navigation Mode

Database tools of IntelliJ also provide special navigation behavior. In the database tool window, callGo to a symbolAnd enter the table name to quickly jump to the table:

If you useFind usagesFunction, IntelliJ will show all the tables that reference it:

Even more ecstatic, IntelliJ can navigate you to other tables based on the usage of primary keys. For example, you can ask the IDE to display in other tables, Which Rows reference the primary key value when moving forward:

21. bookmarks

Let's take a look at the last important behavior-Navigate to any location you are interested in through bookmarks. IntelliJ provides a very convenient tool to implement this function. Press F11 to add or delete the current position in the bookmarks ). Once the add operation is complete, you can see a corresponding icon in gutter. Then, whenever you want to return the position saved as a bookmarkdonefile, click Shift + F11 and select from the list:

Summary

I hope this article will give you a preliminary understanding of how to use IntelliJ's powerful navigation function to quickly switch between your own code, so that you can focus on your code. In other words, the less time you spend on switching, the higher your production efficiency.

In addition, remember to learn more about your IDE, and your programming life will become more comfortable.

IntelliJ IDEA: Adding fonts to anti-aliased

IntelliJ IDEA 12 create a Web project graphic tutorial

Graphic tutorial for Android program development using IntelliJ IDEA

IntelliJ IDEA 12 haXe NME application Configuration Guide

IntelliJ IDEA test mode for running the Play Framework

Install IntelliJ IDEA 12 on Ubuntu 13.04

IntelliJ IDEA 12 create a Java Web project managed by Maven (illustration)

IntelliJ IDEA details: click here
IntelliJ IDEA: click here

Original article: dzone Translation: ImportNew.com-elviskang
Http://www.importnew.com/15462.html.

This article permanently updates the link address:

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.