Thursday, October 4, 2012

Re: vim: how to gq a visual block?

On 10/04/2012 02:04 PM, ping wrote:
>
>
> On 10/04/2012 12:04 PM, Charles Campbell wrote:
>> ping wrote:
>>> as in subject, suppose we have a gq'ed block already:
>>>
>>> 0 1 2
>>> 12345678901234567890123456789
>>> lsdjflsdlksjfsdlfjsld 123
>>> lsjfsdfksdjfldsfsdlsl 456
>>> lsjdlfsdlfjsalfslfsjs 789
>>>
>>>
>>> now I want to re-format the character blocks , for example, extend
>>> them from current length 21 to some other length, say, 25, or squeeze
>>> to 18, without affacting the "digit blocks".
>>>
>>> is it possible at all with any command or plugins?
>>>
>> Not a perfect solution, because the righthand side digits may move (as a
>> column) a bit, but:
>>
>> * set tw=(new value here)
>> * ctrl-v block of characters
>> * :B norm! gqap
>>
>> That also assumes that the text within is a paragraph, too.
>>
>> The ":B" is supported by my vis plugin:
>>
>> You can get vis.vim from:
>>
>> http://vim.sourceforge.net/scripts/script.php?script_id=1195
>> (stable)
>> http://www.drchip.org/astronaut/vim/index.html#VIS (cutting
>> edge)
>>
>> Regards,
>> C Campbell
>>
>
> thanks! I was just thinking to look at your vim website for some help...
>
> but it looks not always work well, sometime it even change the text
> sequences, is there any internal "sort" in the process flows?
>
>
> the example text:
>
> LUCY CRAFT: Japan and China 'normal
> 40 years ago and i n terms of econom
> relations, are lit erally 'joined'
> their cross-border trade reaching $
> last year. Their p olitical relation
> meanwhile, has bee n a constant sour
> And yet while anti -Japanese 'hostil
> has 'flared up' re peatedly over the
> the recent widespr ead 'fury' target
> government offices and businesses o
> week, 'blindsided' many here - like
> 72-year-old 'green grocer' Hiroko Iw
>
>
>
> I set tw=50, c-v selected the left block, move cursor to the bottom CHAR
> 'n', then :B normal! gqap
> and I got this:
>
>
>
> Their p meanwhile, has and China 'normal n
> terms
> bee And yet while anti of econom erally
> 'joined'
> has 'flared up' re the trade reaching $
> olitical
> recent widespr relation n a constant
> sour
> government offices week, -Japanese 'hostil
> peatedly
> 'blindsided' 72-year-old over the ead 'fury'
> target
> 'green and businesses o many
> here
> - like grocer' Hiroko Iw
> LUCY CRAFT: Japan 40
> years ago and i
> relations, are lit their
> cross-border last year.
>
>
> so the text block that I applied the gqap just got indented, making them
> looks like 50 textwidth, but not re-wrap the whole block?
>


"That also assumes that the text within is a paragraph, too."

oh I got it, I have to test it with these text, making it "within a
parag"...

LUCY CRAFT: Japan and China 'normalized ties'
40 years ago and in terms of economic
relations, are literally 'jo ined' 'at the hip';
their cross-border trade rea ching $340 billion
last year. Their political r elationship,
meanwhile, has been a consta nt source of 'tension'
And yet while anti-Japanese 'hostility' in China
has 'flared up' repeatedly o ver the years,
the recent widespread 'fury' targeted at Japanese
<\n> <---- must have a new line here


it work!

on the other hand, sometime it doesn't work well...

see I have this texts:

LUCY CRAFT: Japan and China 'normalized ties' aaaaaaaaaaa
40 years ago and in terms of economic aaaaaaaaaaa
relations, are literally 'joined' 'at the hip'; aaaaaaaaaaa
their cross-border trade reaching $340 billion aaaaaaaaaaa
last year. Their political relationship, aaaaaaaaaaa
meanwhile, has been a constant source of 'tension'. aaaaaaaaaaa
And yet while anti-Japanese 'hostility' in China aaaaaaaaaaa
has 'flared up' repeatedly over the years, aaaaaaaaaaa
the recent widespread 'fury' targeted at Japanese aaaaaaaaaaa
government offices and businesses over the last aaaaaaaaaaa
week, 'blindsided' many here - like aaaaaaaaaaa
72-year-old 'greengrocer' Hiroko Iwasaki. aaaaaaaaaaa


now I set tw=60 and a :B normal! gqap turned it into:

LUCY CRAFT: Japan and China 'normalized ties' 40 aaaaaaaaaaa
years ago and in terms of economic relations, aaaaaaaaaaa
are literally 'joined' 'at the hip'; their aaaaaaaaaaa
cross-border trade reaching $340 billion last year. aaaaaaaaaaa
Their political relationship, meanwhile, has aaaaaaaaaaa
been a constant source of 'tension'. And yet while aaaaaaaaaaa
anti-Japanese 'hostility' in China has 'flared up' aaaaaaaaaaa
repeatedly over the years, the recent aaaaaaaaaaa
widespread 'fury' targeted at Japanese government offices aaaaaaaaaaa
and businesses over the last week, 'blindsided' many
aaaaaaaaaaa
here - like 72-year-old 'greengrocer' aaaaaaaaaaa
Hiroko Iwasaki. aaaaaaaaaaa

now look at:
'normalized ties' 40
economic relations,
hip'; their
....


why there are many gaps between the last word of each line to the
previous word?


thanks!

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: