vim - Replace ANSI color code from string in vimscript -


i have string variable in vimscript contains ansi escape characters used highlighting purposes. string looks like,

^[[32m mystringbody ^[[0m 

i've put escape code literally vim displays it, escape sequence - ctrl-v-[.

i want replace occurences of such escape characters substitute command.

substitute(my_variable, pattern, '', 'g') 

can me regex pattern remove these escape characters. thanks.

the special atom \e matches <esc> = ^[:

substitute(my_variable, '\e\[[0-9;]\+[mk]', '', 'g') 

you use \%d27 (<esc> decimal 27) or \%x1b (hexadecimal). pattern should match (most) ansi escape sequences.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -