14

How do I make all occurrences of a phrase (search term) in a file to be highlighted in the VS code editor?

10 Answers 10

16

I noticed that a nice side effect of the Rock-Scroll plugin is that when you double-click a keyword it highlights all occurrences in the file (and in the rock scroll preview) as well.

http://microsoftdev.blogspot.com/2008/05/rock-scroll-visual-studio-plugin.html

Hope that helps, Alex

Sign up to request clarification or add additional context in comments.

1 Comment

This will save me from having to use Notepad++ so much.
11

ReSharper can do this with the Highlight Usages feature: Highlight Usages In File

Course, you need ReSharper ;)

Comments

7

I have just done a quick google for this very feature.

Came up with these results

VS 2008 http://visualstudiogallery.msdn.microsoft.com/en-us/ad686131-47d4-4c13-ada2-5b1a9019fb6f

VS 2010 http://visualstudiogallery.msdn.microsoft.com/en-us/4b92b6ad-f563-4705-8f7b-7f85ba3cc6bb

Comments

7

You can use metalScroll extension - it is like rockscroll but it has rich and very useful functions. You can download this on:

http://code.google.com/p/metalscroll/downloads/list

go through with this before use:

http://code.google.com/p/metalscroll/

Comments

6

When you run a "find" you can click "bookmark all" which will identify on the left which lines the search terms occur on, but you can't "highlight" the elements using visual studio, out of the box.

1 Comment

I use this but in one case, all the occurences I wanted were on the same line of code, so it only bookmarked the one line :/
4

If you use the CTRL-i short cut, it'll do an inline incremental search. Keep pressing CTRL-i to jump to & highlight each subsequent occurence in the file.

I'm not sure that you can highlight all occurences at once. It may be possible with a plugin like ReSharper but not that I'm aware of.

Comments

3

Microsoft has an (actually) useful VS plugin which solves this issue.

Power Tools: http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef/

Once installed (restart VS afterwards), either highlight a section of text an hit CTRL+F to iterate all occurrences, or highlight text and let VS mark all matches for you in syntax highlighting.

1 Comment

Hmmm....with the improved Find/Replace UI, it's a lot more streamlined than I expected (hit escape to dismiss the toast and un-highlight the terms), but I still miss [Rock|Metal]Scroll's immediate highlighting of terms on double-click.
2

CTRL + F3

  • sends current word to find, regardless if it is selected or not
  • steps to the next occurrence
  • AND highlights all occurrences in editor

TIP: Use SHIFT+CTRL+F3 to "step backwards"

2 Comments

This is simply amazing! Unless I close the search box, it keeps highlighted words even while editing! +1
This is an amazing find!
0

I copied and pasted the source code into Word 2007. This has highlight all option called 'Reading Highlight'. This keeps the highlighting on even when you search for another term.

1 Comment

I do the same thing with Notepad++
0

I open the file in Notepad++ and VS.

Update:

I recently found this extentnion for VS that makes it behave like notepadd++! You just need to select a phrase and it will highlight all of them.

Highlight all occurrences of selected word

1 Comment

despite it's a little unconvenient, open the file in Notepad++ is actually not a bad idea.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.