Sublime Forum

Colourise Line when a column has a particular character

#1

Hello,

I have just started using Sublime Text and would like to know if the it is possible to colourise a line if a column has a particular character.

Sometimes I need to scan through a log file to find errors (and warnings), it would be easier to spot non-informational messages if the lines were different colours depending on the type of message. Using the dummy log file below as an example, the important character is in column 23 (100I, 200W & 400E etc…).

13/08/15 15:31:20 100I Daemon initialized 13/08/15 15:31:21 200W Security disabled. 13/08/15 15:31:22 300I Retrieving configuration from server 13/08/15 15:31:23 400E Server cannot be reached 13/08/15 15:31:24 600I Daemon terminating 13/08/15 15:31:25 700S Failed to open port 123456

Key:

I - Information
W - Warning
E - Error
S - Severe Error

Regards,
Steven

0 Likes

#2

Yes, there is two ways for this.

  1. You define a new syntax definition that utilizes look-aheads and then assigns a scope to the entire line
  2. You write a plugin that uses the View.add_regions API.
0 Likes