0

Atom is a hackable text editor but I can't find a way to hack it to my needs. On PC I use Notepad++ and its custom highlighting engine to view very large log files with visual cues to assist me.

I want to be able to highlight individual lines in Atom based on their contents: say the line contains "warning" I want it to be orange or "error" - red.

Sten Petrov
  • 10,943
  • 1
  • 41
  • 61

1 Answers1

0

Atom is build on web technologies, so you can use JavaScript and CSS to alter its behaviour. If, for instance, you type "Warning" into a plain-text document and open the Developer Tools, you will see it is rendered as plain HTML:

<span class="text plain"> <span class="meta paragraph text">Warning</span> </span>

Unfortunately, there are currently no CSS selectors for the text inside a tag-pair, so you would have to create a plugin, or package, in JavaScript/Coffeescript. How to CSS: select element based on inner HTML) provides a good starting point.

Use JavaScript to detect all instances of “Warning” inside the HTML of the editor view, then add a class. You can then use CSS to highlight the line.

Alternatively, you could probably create custom grammar for your log file.

Community
  • 1
  • 1
idleberg
  • 12,634
  • 7
  • 43
  • 70
  • That's not what I'm asking. My file has unstructured log data, such as [2016-05-31 17:10:12] [Warning] Something happened and was logged, I want to highlight all [Warning] lines in my files – Sten Petrov Jun 02 '16 at 18:12
  • I understood that, maybe my answer wasn't clear enough. Edit incoming! – idleberg Jun 02 '16 at 22:15