IntelliJ IDEA 小贴士

阮喜
2023-12-01

IntelliJ IDEA 快速指南

To quickly find and run an inspection, press Ctrl+Alt+Shift+I and start typing the name of the inspection or its group. Choose an inspection from the suggestion list and specify the scope.

  1. 要快速查找并运行检查,请按 Ctrl+Alt+Shift+I 并开始键入检查或其组的名称。从建议列表中选择一个检查并指定范围。

You can view all statements within the method where certain exceptions can be thrown. Place the caret at the throws statement and press Ctrl+Shift+F7

  1. 你可以查看方法中可能引发某些异常的所有语句。将插入符号放在 throws 语句中,然后按 Ctrl+Shift+F7

To open your browser with the documentation page for the element at the caret, press Shift+F1 (View | External Documentation).
To use this feature, a browser must be selected on the Tools | Web Browsers page of the Settings/Preferences dialog Ctrl+Alt+S.

  1. 要使用插入符号处元素的文档页面打开浏览器,请按 Shift+F1(查看外部文档)。
    要使用此功能,必须在 “ 设置/首选项 ” 对话框的 “ 工具 Web 浏览器”页上选择浏览器 Ctrl+Alt+S。

Kotlin is a powerful, concise and expressive language crafted by JetBrains.IntelliJ IDEA supports it out-of-the-box.To create a Kotlin file, right-click the target folder, and choose the corresponding option on the New menu

  1. Kotlin 是由 JetBrains.IntelliJ IDEA 公司精心打造的一种强大、简洁、富有表现力的开箱即用的语言。要创建一个 Kotlin 文件,右键单击目标文件夹,然后在 “ 新建 ” 菜单上选择相应的选项。

In IntelliJ IDEA Community, you can configure different copyright notices for different sets of files. For convenience, you can use variables. For example, use $ today.year to keep the year up to date. In the Settings/Preferences dialog Ctrl+Alt+S, select Editor | Copyright | Copyright Profiles, create a new profile, and add the text for your copyright notice using variables.

  1. 在 IntelliJ IDEA 社区版中,可以为不同的文件集配置不同的版权声明。为了方便起见,可以使用变量。例如,使用 $today.year 使这一年保持最新。在 “ 设置/首选项 ” 对话框 Ctrl+Alt+S ,选择 “ 编辑器|版权 | 版权配置文件 ” ,创建新的配置文件,并使用变量添加版权声明的文本。

To quickly wrap a code block in useful constructs, select it in the editor and press Ctrl+Alt+T (Code | Surround With).The list of available options or wrappers is context-sensitive and depends on the language. For example, you can surround html blocks with tags, and so on.

  1. 要在有用的构造中快速包装代码块,请在编辑器中选择它,然后按 Ctrl+Alt+T(Code | Surround With)。可用选项或包装器的列表与上下文相关,并取决于语言。例如,可以用标记包围 html 块,等等。

Use Refactor | Copy to create a class which is a copy of the selected class.This is useful when you need to create a class similar to an existing one, and it’s not feasible to put shared functionality in a common superclass.

  1. 使用 Refactor | Copy 创建一个类,该类是所选类的副本。当你需要创建一个类似于现有类的类,并且将共享功能放在公共超类中是不可行的,这一点非常有用。

You can get familiar with the main features of the IDE by following these tips. You can try out the features without closing this dialog. If you close it, you can always get back to it by selecting Help | Tip of the Day from the main menu.

  1. 通过以下提示,你可以熟悉 IDE 的主要特性。你可以在不关闭此对话框的情况下尝试这些功能。如果你关闭它,你可以通过从主菜单中选择 Help | Tip of Day 返回到它。

Press Ctrl+D in the editor to duplicate the selected block, or the current line when no block is selected.

  1. 在编辑器中按 Ctrl+D 可复制选定的块,粘贴到没有被选中的块。

Code Completion can suggest a name for a variable when you declare it. For example, start typing private FileOutputStream and press Ctrl + 空格

  1. 代码完成可以在声明变量时建议变量的名称。例如,开始键入private FileOutputStream,然后按 Ctrl+空格

Press Shift twice to search for a file, action, class, symbol, or even a UI element across your project. Pressing double Shift again will extend the search to non-project items. You can also click in the upper-right corner of the product window.

  1. Shift 键两次可在整个项目中搜索文件、操作、类、符号甚至 UI 元素。再次按两次 Shift 将把搜索扩展到非项目项。您也可以单击产品窗口的右上角。

To switch between opened files and tool windows, use the Switcher Ctrl+Tab. For navigation, press and hold Ctrl (on Windows and Linux) / Ctrl (on macOS) and use the Up and Down arrow keys or Tab and Shift+Tab, and Alt. Press Delete or BackSpace to close an editor tab or hide a tool window.

  1. 要在打开的文件和工具窗口之间切换,请使用 Switcher Ctrl+Tab。对于导航,请按住Ctrl(在Windows和Linux上)/Ctrl(在macOS上)并使用上下箭头键或Tab和Shift+Tab和Alt。按 Delete 或 BackSpace 可关闭编辑器选项卡或隐藏工具窗口。

You can create code constructs using statement completion. Start typing a method declaration, a method call or a statement such as if, do-while, try-catch, or return. Press Ctrl+Shift+Enter to complete the statement into a syntactically correct construct.

  1. 你可以使用语句补全来创建代码构造。开始键入方法声明、方法调用或 if、do while、try catch 或 return 之类的语句。按 Ctrl+Shift+Enter 将语句插入到语法正确的构造中。

To navigate to the implementations of an abstract method, position the caret at its usage or its name in the declaration and press Ctrl+Alt+B.

  1. 要导航到抽象方法的实现,请将插入符号放在其用法或声明中的名称处,然后按 Ctrl+Alt+B

You can drag an external file from Explorer or Finder and drop it onto the Favorites tool window Alt+2.

  1. 您可以从 “ 资源管理器 ” 或 “ 查找器 ” 中拖动外部文件并将其放到 “ 收藏夹 ” 工具窗口 Alt+2

If you do not remember a live template abbreviation, press Ctrl+J to see a list of suggestions for the current context. For example, type it and press Ctrl+J to see what happens.

  1. 如果不记得活动模板的缩写,请按 Ctrl+J 查看当前上下文的建议列表。例如,键入它,然后按 Ctrl+J 查看会发生什么。

To see the inheritance hierarchy for the selected class, press Ctrl+H (Navigate | Type Hierarchy). You can also invoke the hierarchy view directly from the editor to see the hierarchy for the currently edited class.

  1. 要查看所选类的继承层次结构,请按 Ctrl+H(Navigate | Type hierarchy)。您也可以直接从编辑器中调用层次结构视图来查看当前编辑的类的层次结构。

Pressing the same shortcut after you have invoked Smart type completion (Ctrl+Shift+空格) when there’s an array of the expected type in the context will suggest getting an element from this array.

  1. 当上下文中有一个预期类型的数组时,在调用智能类型完成(Ctrl+Shift+空格)后按相同的快捷方式将建议从该数组中获取元素。

To quickly select the currently edited element (class, file, method, or field) in another view, for example, Project or Structure, press Alt+F1 or call Navigate | Select In.

  1. 若要在另一个视图(例如,项目或结构)中快速选择当前编辑的元素(类、文件、方法或字段),请按 Alt+F1 或调用 Navigate | select in

To use text patterns in Search Everywhere (double Shift) when searching for a class, file, or symbol. Use * and space:

  • *stands for any number of arbitrary characters.
  • space marks the end of a pattern. The preceding string is considered not just a prefix but a whole pattern. The list of the suggested names is narrowed down accordingly.
  1. 在搜索类、文件或符号时在 “ 到处搜索 ” 中使用文本模式(双移位)。使用*和空间
    *表示任意数量的任意字符。
    空格表示图案的结束。前面的字符串不只是一个前缀,而是一个完整的模式。建议的名单相应缩小。
 类似资料: