开发者

How to search string under cursor in Eclipse

In vim, pressing * in command mode performs an automatic search of the word under the cursor.开发者_如何学JAVA How can I obtain the same in Eclipse?


A combination of two keystrokes:

  1. First, hit Ctrl + Shift + Right Arrow to invoke "Select Enclosing Element". This will select the word under your cursor.
  2. Use Ctrl + K (Cmd + K on OS X) to "find next".


It appears it was not possible in 2004, and it's still not possible, apparently. I'm speechless...


I also need this functionality and created a small plug-in which adds commands for doing this. You can download it and find more details here: http://eclipselabs.org/p/eclipse-tweaks/


Windows 10, tested on Eclipse 2020-03:

Two Steps:
1. Alt + Shift + Up Arrow, to select the word under the cursor
2. Ctrl + K to find the selected word forward
(Ctrl + Shift + K to find the selected word backward)

NOTE:
If you are inside an XML tag, Alt + Shift + Up Arrow will select from the beginning of the tag to the end tag, including all enclosing elements. Try it!

BONUS:
Ctrl + Shift + Down/Up arrows to navigate methods, as sometimes the selected word is a method you want to go to.

Better still, Ctrl + O - Go to a specific method, by searching (Just enter the first few letters of the method, and Enter)

Cheers


Press Ctrl + k on a Windows machine. On a Mac, Cmd + k should work (seen here).


Not exactly the same, but maybe helpfull if you work with java. In a .java file you can press

CTRL + SHIFT + u

to find occurences in the same source file.


You can also use Shift + Ctrl + K to search next backwards.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜