I have a file with 100s of lines of data with the following format:
Smith, [email protected], 271Ave
Doe, [email protected], 270Ave
.
.
and so on
I would like to change the all the entires into the following format:
{"name": "Smith", "email": "[email protected]", "Address:" "271Ave"}
Please suggest as to how this can be achieved in vim.
Doing it with vim is easy, if each line has same text format. Open the file in vim, assume your cursor at line1, then record macro in register q
:
qqI{"name": "<esc>f,i"<esc>wi"email": "<esc>;i"<esc>wi"Address:" "<esc>A"}<esc>+q
then replay the macro 200 times (you can give 999, if you have more than 200 lines)
200@q
you will get the desired output. You can also use nesting macro so that you don't have to type the 200
.