3

How do you insert literal control characters in vi on Mac?

For example what is the Mac equivalent of

Unix ^V^M Windows ^Q^M (in vim)

to insert a \r into a substitution string?

7

It's the same like in Unix/Linux:

^V^M

But, if you want to use the character in a substitution string, then you should write it like it is, \r, e.g.

:%s/blabla/\r/
  • Thank you. The trick for others who are trying to de-Windows their brains, is to use the actual ^ (control) key not the command key that you think is the mac version of the control key (because it usually is) and to use the actual M key for ^M not the Enter key that works equally well in vim on Windows. – jay613 Sep 2 '18 at 11:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .