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

查看:38
本文介绍了如何在 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+Down(在 OSX 上,Ctrl+Down),之前的方法 Alt+Up(在 OSX 上,Ctrl+Up - 这在 Mac 上被 Mission 覆盖通过转到系统偏好设置">键盘">快捷方式">任务控制"来控制和修复.)

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+UpCrtl+Alt+向下

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

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

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+]

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 UpPage Down 将滚动显示当前可见代码上方或下方的行.

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

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

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