Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I fill text in vi?

3 views
Skip to first unread message

Alan Mackenzie

unread,
Oct 30, 2009, 3:29:36 AM10/30/09
to
Yes, that's vi as in vi, not the more forceful vim.

By filling I mean, of course, taking a ragged paragraph of text and
reformatting it so it fits neatly into a maximum width of (say) 73
columns - what one might do with "g q }" in vim.

Also, having vi wrap at the said column whilst typing would be nice.
Is there a way of doing this?

Thanks in advance!

--
Alan Mackenzie (Nuremberg, Germany).

SM

unread,
Oct 30, 2009, 4:53:19 AM10/30/09
to
2009-10-30, Alan Mackenzie skribis:

>
> By filling I mean, of course, taking a ragged paragraph of text and
> reformatting it so it fits neatly into a maximum width of (say) 73
> columns - what one might do with "g q }" in vim.

In vi, I'd probably do

:%!fmt

> Also, having vi wrap at the said column whilst typing would be nice.
> Is there a way of doing this?

Probably. Sorry.

--
kasmra
:wq

Alan Mackenzie

unread,
Oct 30, 2009, 1:25:28 PM10/30/09
to
Hi, SM!

SM <kas...@ne-spamon.gmail.com> wrote:
> 2009-10-30, Alan Mackenzie skribis:

>> By filling I mean, of course, taking a ragged paragraph of text and
>> reformatting it so it fits neatly into a maximum width of (say) 73
>> columns - what one might do with "g q }" in vim.

> In vi, I'd probably do

> :%!fmt

This doesn't do quite what I want. It fails to preserve prefices like
">> >" in newsgroups postings. But I forgot to say I wanted this. But
thanks muchly for the idea of using an external program (which hadn't
occurred to me). I've hacked an AWK script which DTRT, more or less, and
then mapped the key `q' to invoke it on the current paragraph.

>> Also, having vi wrap at the said column whilst typing would be nice.
>> Is there a way of doing this?

> Probably. Sorry.

Hey, you've nothing to apologise for. ;-) I found out there's an option
`wraplen' (aka `wl') on my ISP's vi which does just what I want.

So, all in all, a totally successful hack. Thanks for the tip!

Peter Gordon

unread,
Oct 30, 2009, 3:39:47 PM10/30/09
to
SM <kas...@ne-spamon.gmail.com> wrote in
news:slrnhelabv...@ananas.Sauna:

set wm=10 will cause the line to hard wrap at column 70.
It assumes the old ASCII screens of 80 characters width.

Florian Rehnisch

unread,
Oct 31, 2009, 12:04:42 AM10/31/09
to
o Alan Mackenzie <a...@muc.de>:

> SM <kas...@ne-spamon.gmail.com> wrote:
>> 2009-10-30, Alan Mackenzie skribis:

>>> By filling I mean, of course, taking a ragged paragraph of text and
>>> reformatting it so it fits neatly into a maximum width of (say) 73
>>> columns - what one might do with "g q }" in vim.

>> In vi, I'd probably do

>> :%!fmt

> This doesn't do quite what I want. It fails to preserve prefices like
> ">> >" in newsgroups postings. But I forgot to say I wanted this. But
> thanks muchly for the idea of using an external program (which hadn't
> occurred to me). I've hacked an AWK script which DTRT, more or less, and
> then mapped the key `q' to invoke it on the current paragraph.

“par” handels prefixes and suffixes, according to its manpage.
--
flori
Vim-Hilfe auf Deutsch http://www.florianrehnisch.de/vimhelp/
Mein Zigarettenkonsum der letzten sieben Tage:
Fr:27 Sa:29 So:30 Mo:25 Di:31 Mi:35 Do:30

Geoff Clare

unread,
Nov 3, 2009, 8:21:03 AM11/3/09
to
Peter Gordon wrote:

>>> Also, having vi wrap at the said column whilst typing would be nice.
>>> Is there a way of doing this?

> set wm=10 will cause the line to hard wrap at column 70.


> It assumes the old ASCII screens of 80 characters width.

It should wrap at 10 columns from the right margin, regardless of
the terminal width. If you have a version of vi that wraps at
(80-wm) instead of (width-wm) when the width isn't 80, that's a bug.

--
Geoff Clare <net...@gclare.org.uk>


Alan Mackenzie

unread,
Nov 3, 2009, 5:36:48 PM11/3/09
to

On "my" vi, there's an option "wraplen" (abbreviated "wl") which you set
to the amount of text you want to wrap, not the size of the hole you want
to leave after it. This is a vi on FreeBSD, but I don't know how to get
this vi to display its version number.

0 new messages