Friday, August 17, 2012

VIM join every other line

I've received a long list of changed passwords for Office365 and they are delivered via email in the format:
User Name: xxxx
Temporary Password: xxxx

in HTML.

It's not very useful, but I could copy this list into vim. Now, how do I combine the username and password into a single row?
250 times Jj is kinda bad. what else can I do?
:g/User/j

Yeah, that's about it.
I suppose I could substitute all spaces for commas
:%s/ /,/

Nice, but now I don't really need User Name:, and Temporary Password:,
:%s/User Name:,//
:%s/Temporary Password:,//

Is there a trailing comma? Let's get rid of it
:%s/,$//

I should be able to save this as a .csv now!

No comments:

Blog Archive