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?
if/else condition for matching a regex in a file
search;regular expression;functions
You can use the search() function. Something like this should work:if search('\e\[\d\+;\d\+m', 'nW')>0