How to search inside a specific block of code in IntelliJ IDEA?

点点圈 提交于 2019-12-22 08:00:06

问题


How I can search within a specific block of code or selection in IntelliJ IDEA?

I got used to using this feature in Eclipse. In Eclipse you can just double click on the beginning of a curly bracket, and it'll highlight the entire block of code. After which you could do Command+f
(Ctrl+f on Windows) to search ONLY in the highlighted block, or you could just highlight whatever you need and search just that block of code.


回答1:


Go to Settings | Keymap, search for the Find... action in the Other group. This action should have the following description:

Find a string in active editor, shows modal dialog

Assign a keyboard shortcut to this action (you need to make a copy of default keymap to modify it), for example Ctrl+Alt+Shift+F.

When in editor, select any block of text, then press this shortcut, a dialog will open with the Scope automatically set to Selected text:

To quickly select the method body while standing on the opening curly brace use Ctrl+W.




回答2:


First select some text and press ctrl+R to open the dialog, then check the "in selection" option :



来源:https://stackoverflow.com/questions/6208633/how-to-search-inside-a-specific-block-of-code-in-intellij-idea

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