long line to paragraph all indented

13 views
Skip to first unread message

Tim Johnson

unread,
Jun 3, 2019, 5:43:18 PM6/3/19
to vim ML
version 7.4 on ubuntu
non-gui

given a long line indented to some nominal number of spaces, how can
I format this line to preset paragraph width but with each line in
paragraph retaining the original indentation.
example:

Pour the remaining sauce over the enchiladas. Cover with leftover cheese and bake for about 20 minutes or until cheese is bubbling.

becomes:

Pour the remaining sauce over the enchiladas. Cover with leftover cheese
and bake for about 20 minutes or until cheese is bubbling.

thanks
--
Tim Johnson
http://www.tj49.com

George Dinwiddie

unread,
Jun 3, 2019, 5:50:26 PM6/3/19
to vim...@googlegroups.com
Tim
I use the external program 'fmt' to do it, like this:

:.,.!fmt

Does that give you the results you want?

- George

--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach
----------------------------------------------------------------------

Gary Johnson

unread,
Jun 3, 2019, 5:50:39 PM6/3/19
to vim ML
:set breakindent

Regards,
Gary

Gary Johnson

unread,
Jun 3, 2019, 6:00:57 PM6/3/19
to vim...@googlegroups.com
On 2019-06-03, George Dinwiddie wrote:
> Tim
>
> On 6/3/19 5:43 PM, Tim Johnson wrote:
> >version 7.4 on ubuntu
> >non-gui
> >
> >given a long line indented to some nominal number of spaces, how can
> >I format this line to preset paragraph width but with each line in
> >paragraph retaining the original indentation.
> >example:
> >
> > Pour the remaining sauce over the enchiladas. Cover with leftover cheese and bake for about 20 minutes or until cheese is bubbling.
> >
> > becomes:
> >
> > Pour the remaining sauce over the enchiladas. Cover with leftover cheese
> > and bake for about 20 minutes or until cheese is bubbling.
>
> I use the external program 'fmt' to do it, like this:
>
> :.,.!fmt
>
> Does that give you the results you want?

Perhaps I misunderstood. If you want to actually reformat the line,
not just change the way it's displayed, then the normal-mode command

gqq

should do it. You may have to set 'autoindent' as well. See

:help 10.7
:help gq

Regards,
Gary

Tim Johnson

unread,
Jun 3, 2019, 6:48:34 PM6/3/19
to vim...@googlegroups.com
* George Dinwiddie <li...@iDIAcomputing.com> [190603 13:58]:
> Tim
>
> On 6/3/19 5:43 PM, Tim Johnson wrote:
> > version 7.4 on ubuntu
> > non-gui
> >
> > given a long line indented to some nominal number of spaces, how can
> > I format this line to preset paragraph width but with each line in
> > paragraph retaining the original indentation.
> > example:
> >
> > Pour the remaining sauce over the enchiladas. Cover with leftover cheese and bake for about 20 minutes or until cheese is bubbling.
> >
> > becomes:
> >
> > Pour the remaining sauce over the enchiladas. Cover with leftover cheese
> > and bake for about 20 minutes or until cheese is bubbling.
>
> I use the external program 'fmt' to do it, like this:
>
> :.,.!fmt

:) That works like a charm! Thank you.

Tim Johnson

unread,
Jun 3, 2019, 8:00:38 PM6/3/19
to vim...@googlegroups.com
* Gary Johnson <gary...@spocom.com> [190603 13:58]:
Oh yeah...really simple and avoids using external app.

Erik Christiansen

unread,
Jun 3, 2019, 9:44:09 PM6/3/19
to vim ML
On 03.06.19 13:43, Tim Johnson wrote:
>
> Pour the remaining sauce over the enchiladas. Cover with leftover cheese and bake for about 20 minutes or until cheese is bubbling.
>
> becomes:
>
> Pour the remaining sauce over the enchiladas. Cover with leftover cheese
> and bake for about 20 minutes or until cheese is bubbling.

Another data point: With autoindent on, I use gq}, i.e. wrap a
paragraph. Then there's only one thing to remember for wrapping stuff,
long line or wide paragraph.

To minimise keystrokes, I've mapped that to ^W, i.e. "Wrap". (That was
apparently a window command, whatever one of those is. Even after
decades, flicking between buffers with the original commands seems
eminently sufficient. One could use Alt-W, I guess.)

Particularly impressive is that the wrapping, whether gqq or gq},
respects and properly places/adds '> " quote delimiters when wrapping
text quoted as above, making Vim ideal for use within an MUA, in this
case, Mutt.

Erik
Reply all
Reply to author
Forward
0 new messages