How do I go to “next occurrence” in Eclipse

后端 未结 5 1975
执笔经年
执笔经年 2021-02-01 17:30

In Eclipse you can turn on \"Mark Occurrences\", and then it will highlight every occurrence of a given variable in the current scope. That\'s great, but I\'d really like to mo

相关标签:
5条回答
  • 2021-02-01 17:37

    You didn't mention how exactly ctrl+k didn't work for you, but it's what I use in similar circumstances. I put the cursor into or select the word that I'm looking for in the editor and then press ctrl+k to move me to the next occurrence. Since the next occurrence gets selected, I can use the same combination to move forward or press ctrl+shift+k (Find Previous) to move back. (Sorry if that sounds patronizing, but ctrl+k sounds exactly like what you're looking for and I don't know the details of the difficulty you had with it.)

    I agree about the other combinations. If I have to take my hand off the keyboard, I may as well use the scrollbar.

    Best of luck.

    0 讨论(0)
  • 2021-02-01 17:39

    There are a number of SO posts around this. The one that seems to have the best answer is: https://stackoverflow.com/a/12767327/2836515

    Summary: Change the "Next / Previous Annotation" option (Up / Down arrow in the toolbar) to include occurrences and then use CTRL+, or CTRL+. to find next occurrence.

    0 讨论(0)
  • 2021-02-01 17:41

    Use CTRL+K to go to next occurrence and CTRL+SHIFT+K to go to previous occurrence.

    0 讨论(0)
  • 2021-02-01 17:44

    You can do this to maybe reduce some keystrokes/mouse clicks in selecting the initial word:

    1. Put the cursor on the word you're looking for
    2. Hit alt + shift + up
    3. Hit ctrl + k

    This highlights the current word and then does a find next. It doesn't seem to be case-sensitive, though, but that's a small price to pay.

    There are definitely some places it doesn't work, though. Like class and implements in the following (it highlights the whole class):

    public class MyClass implements MyInterface {}
    
    0 讨论(0)
  • 2021-02-01 18:03

    There is a command "Occurrences in File" that is not bound to any key by default. You can run it by pressing Ctrl+3 and then typing occurr. It will put all the current variable in the current file in the Search results. Now Ctrl+. and Ctrl+, will navigate through those occurrences, instead of through the warnings/errors list.

    In order to go back you would want to clean search results. It seems this command does not have a key bound either. It is not even shown as a command in the Ctrl+3 list. But you may also just do another search and it will overwrite the previous one results.

    0 讨论(0)
提交回复
热议问题