4

I want to run a function with a condition that checks for ANSI color escape codes when I open files but I don't know how to write the condition.

I expect it to look something like this:

if ? '^[[0;32m'
    " stuff to do...
endif

(^[[0;32m contains a control character instead a literal '^[')

How do I write this?

0

1 Answer 1

6

You can use the search() function. Something like this should work:

if search('\e\[\d\+;\d\+m', 'nW')>0

Not the answer you're looking for? Browse other questions tagged or ask your own question.