Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On Windows, I use Notepad++ which has the great feature of when I select a word, all instances of that word are also highlighted in the same document. I have found it very helpful for finding patterns in giant log files.

I am wondering if there is a similar feature in a text editor on the Mac. I have looked into the documentation for TextWrangler and TextMate to no avail. Hopefully there is a way to do this so I can be more productive when working on a Mac.

--

Note: in Notepad++ you do not have to do a keyboard shortcut to make this work... you just select some text and it does the highlighting for you automatically.

share|improve this question
    
What happens when you do a "Find" in TextEdit? Does it not highlight all the instances of the text (I apologize; I don't have my Mac in front of me at the moment)? – jrc03c Jul 19 '10 at 16:20
    
In TextEdit, "Find" iterates through each match. I am looking for a way to avoid using a keyboard- or menu-shortcut... just select a word and highlight the other instances of that word in the document. – jedierikb Jul 19 '10 at 16:24
up vote 5 down vote accepted

Sublime Text is able to do that.

share|improve this answer
    
FYI, a Textmate 2 solution is described below. ST is nice also :-) – tim Mar 30 '13 at 21:21

Who said BBEdit couldn't do it?

With your document in the front window:

  • Choose Search > Live Search ⌥ ⌘ F
  • Enter your search string
  • Notice that all instances of that string are now highlighted in your document

To make Live Search go away, click the Done button.

Reference: BBEdit 9.5 User Manual, pages 159-160

share|improve this answer
    
This looks promising! (only been using TextWrangler...). However, reading the documentation, it appears I would still need to enter the query I want into the Live Search field instead of anything I select with the mouse becoming a new Live Search query. – jedierikb Jul 19 '10 at 21:01
1  
Select the text, ⌘C, ⌥⌘F, ⌘V—and you're done. Yes, it's a couple of extra keystrokes, but I don't think that you'll get any closer. If you want to search based on selected text, there's also Use Selection for Find (⌘E), but I don't see that it works with Live Search. – Dori Jul 19 '10 at 22:21
1  
Works in TextWrangler also – Nathan Grigg May 18 '11 at 20:47

In addition to @Tim's answer, but also with input from this message on TextMate's mailing list , one can create the following one-key shortcut:

(
    {   command = 'selectWord:'; },
    {   command = 'copySelectionToFindPboard:'; },
    {   command = 'findAllInSelection:'; },
)

I assigned this to Command-A, and it works quite nicely, highlighting all occurrences of the word under cursor, whether pre-selected or not.

Caveats: this action will scroll the file to the last occurrence of the highlighted word, so one has to manually scroll back. In addition, this will trigger automatic substitution of all occurrences with the typed text ("parallel edit"), which is convenient in many cases but one has to be careful if this is unintended.

share|improve this answer

Well, BBEdit does incremential search. Emacs/Aquamacs and Vim/MacVim do it too of course. This is really an essential feature for me and I am heartbroken that TextMate and SubEthaEdit still have no support for it.

share|improve this answer

Not exactly what you want but TextMate does also have an incremental search.

Hit Ctrl + S and start typing text. What you type will appear in the status bar at the bottom of TextMate window and will also be highlighted in the opened document, if the opened document contains that text..

Hitting Ctrl + S again will select the next match in the document. It is more immediate than Command + S

share|improve this answer

TextMate 2 does this really nicely bound to control-W

This macro [1] is built in.

^W will select a word, but once a selection exists, ^W will add the next instance to the (mult-) selection: Really nice feature!

Even better: double tap the shift key to un-select the last-added instance (great if you overshoot the set you wanted to select.

Even better: All of these are now separate selections, so you can type edit select and it works on each separately, but synchronously. Fabulous time saver!

[1] It's just a macro bound to ^W with a dyn.selection Scope selector

(
    {   command = 'copySelectionToFindPboard:'; },
    {   command = 'findNextAndModifySelection:'; },
)
share|improve this answer
    
thanks @DavidMorales! – tim Nov 26 '15 at 18:49

Lifehacker.com says this is a nice alternative. http://www.fraiseapp.com/

I have no personal experience with it. But it looks nice.

share|improve this answer
    
just tried it -- alas, it does not seem to do what I am looking for. – jedierikb Jul 19 '10 at 19:41
    
Damn. sorry. Was it at least any good (in general)? – alpha1 Jul 21 '10 at 2:05
    
Well, it opened a text file and let me write it in it and save it! :-) – jedierikb Jul 21 '10 at 3:01
    
For future reference, development has been stopped on this program. It is available as a "Mac App" under the name "Smultron" peterborgapps.com/smultron – zourtney Mar 11 '11 at 3:08

When I have switched from Windows to OS/X, I was missing Notepad++. After some research I came into Textwrangler. A feature that I used a lot with Notepad++ was the highlighting of all occurrences of a selected word. Textwrangler did not have this feature so easily accessible. It have such feature but you have to use live search (F), but since the moment that the highlighted text is not filled into live search text box you have to copy the highlighted text (C), fire live search (C) and then paste the text (V)

So since I have a magic mouse and better touch tool installed, I have bound a magic mouse gesture to execute double click (to select the work where the cursor is) + C + F + V

share|improve this answer

Earlier versions of BBEdit may not have been able to do this, but as of version 11, this is possible via:

Preferences -> Editing -> Highlight instances of selected text

Do note that the "free version" of BBEdit, called "TextWrangler", doesn't have this feature (it seems to be one of a number of items reserved for TextWrangler's big brother to sweeten the pot for upgraders).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.