Discussion Locked

Substitute char with newline char in VI

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How do I insert newline characters by using the substitute command in VI?

5 replies

by dennis_herr_jr

I haven't worked with vi or unix in many years so I don't know if this will work but try \^m or maybe \^M. Good luck.

by william shipway

To do this, use Control v.

for example, to substitute a carriage return for the letter X, you would enter the following without the spaces:

: s / X / Ctrl-v /

Depending on the type of newline you want, you might prefer Ctrl-j or Ctrl-m instead of Enter after the Ctrl-v.

HTH
William

This discussion is closed to new replies.