111111111
222222222
333333333
444444444
555555555
666666666
777777777
......
(very long list)
To be environmental friendly, I would like to reformat it as
111111111 222222222 333333333
444444444 555555555 666666666
777777777 ............
Command J should be useful, but I want to know how to automate it to
process to whole file.
Thanks in advance.
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
唐詩172 祖詠 望薊門
燕臺一去客心驚 簫鼓喧喧漢將營 萬里寒光生積雪 三邊曙色動危旌
沙場烽火侵胡月 海畔雲山擁薊城 少小雖非投筆吏 論功還欲請長纓
Pardon, how to set column width?
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
唐詩239 劉長卿 送上人
孤雲將野鶴 豈向人間住 莫買沃洲山 時人已知處
bill lam wrote:
> I have to print on paper something like this,
>
> 111111111
> 222222222
> 333333333
> 444444444
> 555555555
> 666666666
> 777777777
> ......
> (very long list)
>
> To be environmental friendly, I would like to reformat it as
>
> 111111111 222222222 333333333
> 444444444 555555555 666666666
> 777777777 ............
>
> Command J should be useful, but I want to know how to automate it to
> process to whole file.
if you want to have exactly 3 columns in each line you can use
:g/^/normal 3J
If the original line count is not a multiple of 3 you will have to join
the last lines manually
Regards,
Jürgen
--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)
Or you can skip the normal command:
:g/^/j3
I use this all the time :)
-tim
Thank you all for help. I learn three different ways :)
I found a caveat when using gp is that needs set formatoptions-=n to
work so that for my particular case :g is easier to use.
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
唐詩295 杜牧 贈別二首之一
娉娉嫋嫋十三餘 豆蔻梢頭二月初 春風十里揚州路 卷上珠簾總不如
The two join methods ("norm 3J" and "j3") are for literal "I want
to join 3 lines together". The "gq" method is a generic "join
lines to fill the width I specify" which may be more or less than
3 lines joined together. Both have their place, depending on
which type of behavior you want.
As a side note, if you don't want Vim to automatically add spaces
to your joined lines, you can either use "norm 3gJ" or "j!3"
-tim
Thank you for this note, I knew gJ but j! is new to me.
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
唐詩143 劉脊虛 闕題
道由白雲盡 春與青溪長 時有落花至 遠隋流水香
閑門向山路 深柳讀書堂 幽映每白日 清輝照衣裳
!Grs 3
and you'll get exactly what you want. That's quick and easy (but it
requires rs, and for some reason many distros don't include rs
anymore... why?).
--Ted
> 111111111
> 222222222
> 333333333
> 444444444
> 555555555
> 666666666
> 777777777
> ......
> (very long list)
>
> To be environmental friendly, I would like to reformat it as
>
> 111111111 222222222 333333333
> 444444444 555555555 666666666
> 777777777 ............
--
Ted Pavlic <t...@tedpavlic.com>
Sounds like you can get exactly the same thing using the more
standard "pr" command:
:%!pr -3 -t -a
that's "-3" columns without header/footer information ("-t") and
done across ("-a") rather than columnarly. I use "pr -4 -t"
pretty regularly to columnize stuff while working at the
command-line, so it's become second-nature (so much so that I had
to double-check that the "-t" really did suppress headers/footers).
-tim