vi \ ex : Substitute with newline?
|
Original Message
|
Name: caffiene
Date: September 22, 2004 at 08:02:40 Pacific
Subject: vi \ ex : Substitute with newline?OS: Windows 2000 Pro SP3CPU/Ram: P3 600Mhz/256MB |
Comment: Is there a way to use the substitute command in vi to insert carriage returns? I'm looking at a line of data like this: DATA1 DATA2 DATA3 DATA4 DATA5 ... so on I want to break up each DATA entry into separate lines, like so: DATA1 DATA2 DATA3 DATA4 ... so on I was thinking I could substitute the spaces for carriage returns, but I do not know of a way to insert carriage returns with vi. Thanks ahead of time, Carl
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Jim Boothe
Date: September 22, 2004 at 11:59:17 Pacific
Subject: vi \ ex : Substitute with newline? |
Reply: (edit):g/DATA/s/ [ ]*/CtrlVCtrlM/g For all lines containing the string DATA, the above command will change each string of spaces to a newline character. The CtrlVCtrlM are two control characters in a row: Ctrl-V and Ctrl-M That would include one or more spaces at the end of the line as well. If you do not want trailing spaces to be converted to a newline, first remove them with: :g/DATA/s/[ ]*$
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: caffiene
Date: September 22, 2004 at 12:51:01 Pacific
Subject: vi \ ex : Substitute with newline? |
Reply: (edit)Thank you Jim! That works like a charm. I did not realize there were special characters like that that could be put into the substitute command.
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: