Modified Dynamic Highlighter plugin with better support for Chinese users

I’m a user of the Dynamic Highlighter plugin which is another cool plugin that is created by @NothingIsLost

In the ReadMe of the plugin, one of the limitation is described:

  • Only strings with 3 or more characters will be highlighted in selection highlight mode

I guess this may be based on some performance considerations. However, this limitation also brings a huge problem for Chinese users (perhaps, CJK users). Because, traditionally, the ancient Chinese use words containing only 1 character, which means the length of these Chinese words is only 1(for example, "好“ for “good”, ”一“ for “one”)). In precent days, many new words come out, and most of them consisted of 2 characters(for example, "电脑” for “computer”), i.e. with length of 2. Of course, there are idioms which is composed with 4 characters since the ancient time, such as “一目了然”(obvious), but the amount of them is limited.

So, it is better to have the minimum length = 1 so that this plugin can support use cases with Chinese better.

And it works.

Unfortunately, as I’m not an expert on TS, currently, I have not compiled the main.ts successfully. So I made a workaround: manually modify the value of minSelectionLength variable in main.js from 3 to 1.

The modified main.js can be reviewed and downloaded at:

And for people who are also interested in this issue, you can try the SRC or reply me at

Looking forward to more comments

1 Like

I also use the following css snippet to make the dynamic highlighted word occurrences more eye-catching(using thicken red wavy underline):

.cm-matched-word, .cm-matched-string {
  text-decoration: wavy underline var(--text-highlight);
  text-decoration-thickness: 2pt;
}