Tuesday, January 31, 2012

How to find the element number in a comma delimited line in Vi?

Condition: Only single line exists in the file.

In Vi command mode type...

:set number | %s/,/^M/g

^M is a control character printed using the key combination Ctrl+VM. It is the ASCII 13 - Carriage Return.

When this command is executed all the commas will be replaced by carriage returns, thus displaying the elements vertically.

No comments: