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
Post a Comment