Change color of specific text in .txt document and have it persist


#1

Hello everyone,

This is my first time posting, I have read the guidelines and searched the other post but didn’t find one dealing with my question. Which is:

Is there a way to change the color of specific text in a .txt document? I’m aware you can highlight text and change the color of that, but I would like the coloring to persist, even after closing and reopening the document. Think highlighting a subtitle in a word document and changing the color of the subtitle.

My current need for it is as I am writing something, an article say, I would like to add some notes with a different color to distinguish them as my notes/reminders and have them stand out from the article text.

I imagine you can wrap the text in a specific tag and change the color of that tag with the styles.less, if that’s possible in a .txt document, but if that is the solution I would like to not see the tag.

Thank you!


#2

It’s possible, but you’re not going to accomplish it with a theme or the existing highlighting system. You would have to create a package and come up with a way to identify and track a position in a plain-text file even if the text changes. You could do this by having your package remember both the start and end points of your highlight, and making guesses about where to move based on the surrounding text. Sounds like a lot of work. My recommendation is to not use .txt. Instead, use a markdown language that gives you more flexibility, like AsciiDoc, which includes a feature for making notes that stand out from the rest of the text. The Atom package language-asciidoc includes highlighting for admonitions, as you can see here: