Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have few lines that each of them are colon separated values,


Now I could do the reformat with printf plus IFS variable,

while read line; do IFS=":" printf "%-20s %-16s %5d\n" ${line[0]} ${line[1]} ${line[2]}; done < XX

but is it possible to do it within VIM?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Well, in the vi spirit, you'd call a command to do it like:

:%!column -ts:

(if you have column and it supports the -s option).

Otherwise you could do:

:%s/[^:]\+/                                        &/g
:%s/\v^ *([^:]{20}): *([^:]{16}): *([^:]{5})/\1:\2:\3/
share|improve this answer
+1 for column command! – warl0ck Dec 28 '12 at 9:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.