How can I navigate lines of files with the keyboard quicker in IntelliJ?

*爱你&永不变心* 提交于 2019-12-05 14:20:08
Heather92065

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

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

  10. Save your changes and you are ready to use your macro!

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

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. Go into a method hierarchy and then scroll up and down a method list"

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.

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

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:

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

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!