Style all occurrences of text

110 views
Skip to first unread message

Raleigh Rinehart

unread,
Jan 7, 2022, 11:42:38 AM1/7/22
to BBEdit Talk
Hi All, 
I was wondering if there is a way to set a specific style for particular text matches, regardless of what language is selected for the document.

I know there is a Select -> Highlight matches, but this is not quite what I'm looking for.  For one, as soon as the cursor position moves the highlighting turns off, also this feature only allows a single selection to be highlighted at a time.

What I am looking for is something like Notepad++'s "Style Token" behavior.  That is, to be able to select some text and "mark" it with a highlight or different style permanently (until explicitly cleared/"un-marked" by the user).

thanks!

Patrick Woolsey

unread,
Jan 7, 2022, 1:03:48 PM1/7/22
to bbe...@googlegroups.com
On 1/7/22 at 11:28 AM, rale...@gmail.com (Raleigh Rinehart) wrote:

>I was wondering if there is a way to set a specific style for
>particular text matches, regardless of what language is
>selected for the document.
>
>[...]
>
>What I am looking for is[...] to be able to select some text
>and "mark" it with a highlight or different style permanently
>(until explicitly cleared/"un-marked" by the user).


I regret there is not; the closest it's feasible to come at
present would be to create a codeless language module, within
which you can define any desired custom elements.

This is however a "fixed", string/pattern-driven solution rather
than an interactive one of the sort you describe.

(NB: We have previously gotten other requests for this general
capability and it is on our radar; further than that, I cannot
speculate. :-)


Regards,

Patrick Woolsey
==
Bare Bones Software, Inc. <https://www.barebones.com/>


jj

unread,
Jan 8, 2022, 8:31:44 AM1/8/22
to BBEdit Talk
Hi Raleigh,

This Applescript snippet is a bit of a hack that takes advantage of Unicode combining codepoints to create a p͇s͇e͇u͇d͇o͇ ͇u͇n͇d͇e͇r͇l͇i͇n͇e͇ ͇s͇t͇y͇l͇e͇.

It works by inserting the combining underline codepoint (U+0347 COMBINING EQUALS SIGN BELOW) after each character of the selection, skipping linefeeds.

Applying the script on a selection will u͇n͇d͇e͇r͇l͇i͇n͇e͇ it.

Applying the script on a selection that already contains some u͇n͇d͇e͇r͇l͇i͇n͇e͇ will remove all the selection's underlines.

Applying the script when all of the document is selected (after a "Select All") will removes all the document underlines.

You can find / replace / mark the u͇n͇d͇e͇r͇l͇i͇n͇e͇d͇ ͇s͇e͇c͇t͇i͇o͇n͇s͇ with this regular expression:

    ((?:(?:.\x{0347})+\n?)+)

HTH

Jean Jourdain
Reply all
Reply to author
Forward
0 new messages