Home » Questions » Computers [ Ask a new question ]

vim , reformat text for programming

vim , reformat text for programming

I've a big file with lines that look like

Asked by: Guest | Views: 63
Total answers/comments: 2
Guest [Entry]

"The basic conversion is,

sed 's|^\([0-9]\)\(.*\)|{\1,""\2""}|g' file.txt > file2.txt

in vim,

:%s/\([0-9] \(.*\)/{\1,""\2""}/g

This will cover lines starting with the format,

N text on the line...

Where N is a single digit number.
Can be extended further for other forms."
Guest [Entry]

"Does this vim command do what you want ?

%s/^\(.\)\ \(.*\)$/{\1,\ ""\2""},/g"