This question already has an answer here:

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...

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

How do I write this?

marked as duplicate by EvergreenTree, Community Dec 13 '15 at 23:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


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.