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开发者_StackOverflow社区 the way down - but is there an easier way?
How about this:
:%s/\n/\t/
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/
:1,$-1s/$/\t/|%j
Which means:
from the first line to the punultimate 1,$-1
replace the end of the line with a tab s/$/\t/
and then |
for all lines %
join them j
精彩评论