Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search string under cursor in Eclipse

In vim, pressing * in command mode performs an automatic search of the word under the cursor. How can I obtain the same in Eclipse?

like image 852
Stefano Borini Avatar asked Mar 25 '10 06:03

Stefano Borini


4 Answers

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

like image 129
jumping_monkey Avatar answered Oct 11 '22 09:10

jumping_monkey


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".
like image 22
zvikico Avatar answered Oct 11 '22 09:10

zvikico


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

like image 4
Stefano Borini Avatar answered Oct 11 '22 07:10

Stefano Borini


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/

like image 1
rgerganov Avatar answered Oct 11 '22 08:10

rgerganov