nothingislost / obsidian-dynamic-highlights

An experimental Obsidian plugin that highlights all occurrences of the word under the cursor
MIT License
132 stars 7 forks source link

Feature request: word highlight #46

Open Cammagno opened 2 years ago

Cammagno commented 2 years ago

It would be nice to have an option same as line, but highlighting the full word containing the matched string

liamcain commented 2 years ago

If you're comfortable with regular expressions at all, this is already possible.

This will highlight any word containing "test" (including protest, testing, test...):

\w*test\w*

Here's the snippet if you want to import it yourself:

{
  "testing": {
    "class": "testing",
    "color": "#42188038",
    "regex": true,
    "query": "\\w*test\\w*",
    "mark": [
      "match"
    ],
    "css": ".testing { background-color: green !important; }"
  }
}
Cammagno commented 2 years ago

If you're comfortable with regular expressions at all, this is already possible.

Damn, you are right! Thanks! :)