In Vim in iTerm, I frequently encounter issues surrounding line breaks. For example, if I have a file containing the dreaded ^M most online tutorials will say that to perform a replacement I use a regular find and replace on a file like:
%s/^M/^J/g
My problem is that I am unable to enter the ^M - when I type ^V^M (control+V control+M) what is inserted is actually ^J. The result of this replacement is "no occurences found". Am I doing something wrong or could VIM or iTerm be misconfigured somehow?
Some extra info:
- This also occurs in
/usr/bin/viin the Terminal app whenset compatibleis on - Here is an example line through hexdump, which shows the line breaks after the closing square brackets as hex char 0d, which I believe is ^M
00000120 3c 2f 6c 6f 63 3e 0d 20 20 3c 2f 75 72 6c 3e 0d |</loc>. </url>.|