Overriding the css for a range in a TextEditor



I’m developing a package with a key feature depending on the ability to highlight text irrespective of the currently selected language grammar.

A problem I’ve encountered is that the only way I’ve found to highlight the text in the buffer is with a decoration, which has it’s limits as it’s just an overlay on a specific section of text.

I was wondering if there’s a way of overriding the CSS for a range in the text editor or if this simply isn’t possible without a hack that’ll be difficult to maintain.

Thank you for your time


Would using !important work for you?


!important isn’t what I’m looking for, at least not right now. I don’t have a way of applying css to a range in the TextEditor’s buffer yet, all I’ve found so far is Decoration which is only an overlay.

Thank you


Depending on what you want to highlight, you can also highlight text using a grammar. If you look at the language-todo package, you’ll see that you can inject additional rules into other grammars.


Thank you, this looks like one of the best ways to solve my problem.