Here's one possibility. Let's say we have textwidth=40 in mind, and we want to play with Lorem:
Lorem ipsum dolor sit amet, consetetur
sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore
magna aliquyam erat, sed diam voluptua.
At vero eos et accusam et justo duo
dolores et ea rebum. Stet clita kasd
gubergren, no sea takimata sanctus est
Lorem ipsum dolor sit amet.
Let's say we want to move the At vero...
sentence after the Stet clita...
sentence. We might navigate to the At vero...
sentence, use da
s to delete the sentence. Navigate after the Stet...
sentence, p the At vero
sentence after it (perhaps inserting a space if necessary).
This yields
Lorem ipsum dolor sit amet, consetetur
sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore
magna aliquyam erat, sed diam voluptua.
Stet clita kasd
gubergren, no sea takimata sanctus est
Lorem ipsum dolor sit amet. At vero eos et accusam et justo duo
dolores et ea rebum.
but we can gqap to reformat the paragraph to the textwidth, yielding
Lorem ipsum dolor sit amet, consetetur
sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore
magna aliquyam erat, sed diam voluptua.
Stet clita kasd gubergren, no sea
takimata sanctus est Lorem ipsum dolor
sit amet. At vero eos et accusam et
justo duo dolores et ea rebum.
In other words, vim's gq
is sufficiently capable of doing this with repeated application of gq
.
To a certain extent, vim will automatically attempt to format things on the fly if you :set fo=aw2tq
. This is explained in :h formatoptions
and more relevantly :h fo-table
. But in my (limited) experience, it does a mediocre job with the above Lorem ipsum test. But it does very well in handling typing on the fly.