Attach all rows with inserted tabs (vim)

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

:%s/\t/\r/g 

How can I do the inversion after editing the fields? I can write a macro:

 Js<tab>Esc 

And then repeat everything to the end - but is there an easier way?

+6
vim tabs
source share
3 answers

How about this:

 :%s/\n/\t/ 
+12
source share

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

 :%s/\n/\t/ 
+5
source share
 :1,$-1s/$/\t/|%j 

This means: from the first line to an arbitrary 1,$-1 replace the end of the line with the tab s/$/\t/ and then | for all % lines join them j

0
source share

All Articles