Bob
Bob

Reputation: 4970

eclipse - how to enable "mark occurrences" for any text and in all files

If I have a C-file opened and I highlight var1, the editor will automatically highlight all occurrences of var1.

int main()
{
  int var1=0;
  int var2 = var1 + 55;

  return 0;
}

However, it will not highlight all instances of int in the same manner.

Furthermore, if I open a .s file - which is set as type Assembly Source File automatically by CDT - no occurrences will be marked.

In the following assembly file, I'd like occurrences of L97 to be marked when I highlight one occurrence for easy navigation.

    ...
    b   .L97
.L98:
    ldr r0, .L99
    mov r1, r4
    bl  printf
    movs    r0, #0
.L97:
    pop {r2, r3, r4, pc}
.L100:
    ...

How do I enable mark occurrences for all text and in all file types?

In Notepad++, I opened a window, typed two lines of some random text abcd, double-clicked one of them and it automatically highlighted the other without me even setting a file-type.

Upvotes: 1

Views: 457

Answers (2)

howlger
howlger

Reputation: 34165

Notepad++ marks the occurrences of strings, whereas Eclipse marks occurrences of variables.

In the following example, if the first var1 is selected, Eclipse marks only the occurrences of this variable, but neither identically named variables in a different scope nor the string var1 in a comment:

int main()
{
    int var1=0;
    int var2 = var1 + 55;
    {
        int var1 = 42; // var1
        int var11 = 43;
    }
    return 0;
}
int foo()
{
    int var1 = 44;
    return var1;
}

To search and mark a string in one or more files, you can use file search: Search > File....

To jump to the next occurrences of a selected string press Ctrl+K.

Upvotes: 2

greg-449
greg-449

Reputation: 111142

You can't do this for any file type. Occurrence highlighting requires an editor which understands the syntax of the programming language you are editing (Java, C, C++, ....). You would need to find an Eclipse editor for the particular assembly code to get occurrence highlighting.

Upvotes: 0

Related Questions