On linux, using the bash shell, when I use the script command, the generated file is called typescript. When I open that file with vim, each line contains the ^M character, and several lines (due to my colored command prompt) contain a character ^[. I would like to replace these characters with nothing, effectively removing them from the generated script.
First, I tried :%s/^[//gc
, :%s/\^[//gc
, :%s/\^\[//gc
, and a few other variants. None of them matched the ^[ character, so the search/replace didn't work.
I also tried all these variants for the ^M character with the same results. After some googling I discovered that the ^M character is really the carriage return "\r". So then I tried :%s/\\r//gc
and this worked for the ^M character!
I googled some more to try and figure out what the ^[ character is but have found nothing helpful.
2 questions:
1) What is the ^[ character, and what is the appropriate regex to use in vim to search and replace it?
2) Why, when using the script command on linux, does the generated script produce ^M at the end of the line? This makes me think the linux script command is generating CRLF eol characters rather than just LF eol characters.