如何在IntelliJ中使用键盘更快地导航文件行? [英] How can I navigate lines of files with the keyboard quicker in IntelliJ?

查看:180
本文介绍了如何在IntelliJ中使用键盘更快地导航文件行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有键盘快捷键或如何在IntelliJ中将键盘快捷键设置为:

Is there a keyboard shortcut or how can I set up a keyboard shortcut in IntelliJ to either:


  1. 上/下行几行一次(例如5或10)

  2. 在类中向上/向下跳转方法

  3. 进入方法层次结构,然后向上滚动并方法列表

或者是用键盘快速浏览代码文件的更好方法吗?

Or are their better ways to quickly navigate through code files with the keyboard?

推荐答案

IntelliJ非常灵活,有很多快捷方式,很难记住它们。我没有为您的第一个快捷方式请求找到当前的内置解决方案:1。一次上/下几行(例如5或10)

IntelliJ is incredibly flexible with so many shortcuts it's hard to remember them all. I didn't find a current builtin solution for your first shortcut request: "1. Go up/down several lines at a time (e.g. 5 or 10)"

但是,可以创建一个宏并映射到键盘快捷键。请按照下列步骤操作:

However, a macro can be created and mapped to a keyboard shortcut. Follow these steps:


  1. 首先打开要编辑的源文件。

  2. 从菜单中选择编辑 - >
    宏 - >开始宏录制。

  3. 点击源文件,然后按
    按五次。

  4. 从菜单中选择编辑 - >
    宏 - >停止宏录制并命名宏,我使用D5。

  5. 从主菜单中选择文件 - >设置 - >键映射

  6. 在键映射中,向下滚动并找到主菜单。

  7. 展开主菜单,然后展开编辑,再展开宏。

  8. 找到新创建的D5宏并双击它。

  1. First open a source file to edit.
  2. From the menu, select Edit -> Macros -> Start Macro Recording.
  3. Click the source file and then press Down five times.
  4. From the menu, select Edit -> Macros -> Stop Macro Recording and name your macro, I used "D5".
  5. From the main menu, select File -> Settings -> Keymap
  6. Within the key mappings, scroll down and find the Main Menu.
  7. Expand the Main Menu, then expand Edit, and then expand Macros.
  8. Locate the newly created "D5" macro and double click it.

添加所需的键盘映射序列。小心找到尚未使用的快捷方式。我去了 Alt + Shift + 5

Add your desired keyboard mapping sequence. Be careful to find a shortcut not already in use. I went with Alt+Shift+5






2。在类中跳过/关闭方法


"2. Jump up/down a method in a class"

要导航或跳转到下一个方法,请使用 Alt + 向下(在OSX上, Ctrl + 向下),上一个方法 Alt + Up (在OSX上, Ctrl + 向上 - 这在Mac上被Mission Control覆盖,并通过转到系统偏好设置>键盘>快捷方式>任务控制来修复。)

To navigate or jump to the next method use Alt+Down (on OSX, Ctrl+Down), previous method Alt+Up (on OSX, Ctrl+Up - This is overridden on Mac by Mission Control and fixed by going to System Preferences > Keyboard > Shortcuts > Mission Control.)

3。进入方法层次结构,然后向上和向下滚动方法列表

"3. Go into a method hierarchy and then scroll up and down a method list"

要打开Hierarchy Callers面板,当光标位于某个方法上时,按 Crtl + Alt + h

To open the "Hierarchy Callers" Panel, while the cursor is on a method, press Crtl+Alt+h

接下来选择其中一个列表中的呼叫者或方法导航到呼叫。

Next select one of the "callers" or methods within the list to navigate to the call.

要导航到上一个或下一个呼叫者,请按 Crtl + Alt + Up Crtl + Alt + Down

To navigate to the previous or next caller, press Crtl+Alt+Up or Crtl+Alt+Down

要显示类中的方法列表并导航到某个方法,Windows上的 Crtl + F12 OS X上的 F12

To show a list of methods in a class and navigate to a method, Crtl+F12 on Windows or +F12 on OS X

其他导航快捷方式我觉得很有用:

Other navigation shortcut I find useful:

导航到括号内的语句的开头或结尾: Ctrl + [ Ctrl + < kbd>]

To navigate to the beginning or end of a bracketed statement: Ctrl+[ and Ctrl+]

还有许多其他用于导航,选择和代码编辑的快捷方式。要了解更多信息,请打开Keymap设置并进行探索。

There many other shortcuts for navigation, selections and code edits. To learn more open the Keymap settings and explore.

Page Up Page Down 将滚动到显示当前可见代码上方或下方的行。

Page Up and Page Down will scroll to show lines above or below the current visible code.

这篇关于如何在IntelliJ中使用键盘更快地导航文件行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆