I want to format a multiline string according to a textwidth of 32.
group:
- normal: scalar
- multiline: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."
- normal: "text"
to this:
group:
- normal: scalar
- multiline: "Lorem ipsum
dolor sit amet, consetetur
sadipscing elitr, sed diam
nonumy eirmod tempor
invidunt ut labore et
dolore magna aliquyam
erat, sed diam voluptua."
- normal: "text"
My vim settings for this file are
set sw=2 tw=32 et
set formatoptions=tjcroq
For re-flowing paragraphs I frequently use gwap
and formatoptions for on-the-fly formatting. In this case, autoformat is only turned on when in such a section with: fo+=a
but this only works for paragraphs with an empty line before and after the string and does not respect full indentation. My workaround is to add empty lines before and after and delete them afterwards.
This must be a frequent task for most coders here but I don't know how to do it. My guess was to use the marks from the start and end of the current syntax highlighting tag, which is <yamlFlowString>
here, for constraining the auto-formatting to it. Is there any solution to this?
Also see http://vimhelp.appspot.com/change.txt.html#formatting
gq$
from the multi-line?p
by sth else for not applying the reformat to the whole "paragraph" is the right path.