tags:

views:

60

answers:

2

I have a tab delimited file (one line). I can easily enough replace the tabs with new lines so that I can see what fields are in what position

:%s/\t/\r/g

How can I do the inverse, after I've edited the fields? I could record a macro:

Js<tab>Esc

And then repeat it all the way down - but is there an easier way?

+6  A: 

How about this:

:%s/\n/\t/
martin clayton
I was surprised that this actually works. I had no idea that `\n` would do anything at all in a :substitute command's regex.
Laurence Gonsalves
guh - of course. I kept trying to do :%s/$/\t/
EMiller
+4  A: 

You can use s to replace newlines with tabs, basically the reverse of the operation you used to replace the tabs with newlines:

:%s/\n/\t/
sth