Text Editor that hilights all instances of selection for Mac
Solution 1
Sublime Text is able to do that.
Solution 2
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
Solution 3
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).
Solution 4
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.
Solution 5
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:'; },
)
Related videos on Youtube
jedierikb
OB1 Kenobi was the result of an Off-By-One [OB1] error in the clone wars.
Updated on September 17, 2022Comments
-
jedierikb over 1 year
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.
-
jedierikb almost 14 yearsjust tried it -- alas, it does not seem to do what I am looking for.
-
jedierikb almost 14 yearsThis 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.
-
David almost 14 yearsSelect 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.
-
mmmeff almost 14 yearsDamn. sorry. Was it at least any good (in general)?
-
jedierikb almost 14 yearsWell, it opened a text file and let me write it in it and save it! :-)
-
zourtney about 13 yearsFor future reference, development has been stopped on this program. It is available as a "Mac App" under the name "Smultron" peterborgapps.com/smultron
-
Nathan Grigg about 13 yearsWorks in TextWrangler also
-
tim about 11 yearsFYI, a Textmate 2 solution is described below. ST is nice also :-)
-
Pacerier about 6 years@Dori, Is there a particular reason Live Search isn't the default (Ctrl F)?