How to affect selected text using the search feature?

Things I have tried

I’ve tried to bold all numbers within the scope of a note in obsidian. I’ve gotten as far as selecting all the numbers using /[0-9] with the search feature (CTRL + SHIFT + F).

What I’m trying to do

Now that I’ve got all these numbers selected, how can I affect this selected area by turning them to bold text?

I’m not 100% sure of your use case, but the Dynamic Highlights plugin might help

I don’t know, and I can’t seem to make it work, but I thought that Obsidian supported regex (regular expressions) search and replace. But maybe not!? I see a feature request. Maybe there is a plugin. I can’t even match your /[0-9], so I don’t personally know what syntax or feature you are using.

But in Vim key bindings I know you can, if you’re willing to use it:

:%s/(\d+)/**$1**/g

This would change:

This is a note with 1 and 01 and 2 and 4 and 456 and 9
This is a note with 9 and 46 and 3 and 6 and 111 and 2
This is a note with **1** and **01** and **2** and **4** and **456** and **9**
This is a note with **9** and **46** and **3** and **6** and **111** and **2**

You can use regex with Apply Patterns plugin and bind them to a command pallette entry and/or hotkey if you want to use them regularly.

2 Likes

Obsidian supports regex in the file search but not (as far as I know) in find/replace. There are a few plugins that enable it in various ways.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.