2

When I have heredoc and I format it with gq I want it to be aligned in a way so each line starts at the same column like this:

    Long text goes here ...                    80 chars |
    <- whitespace preserved ...                80 chars |
    <- still whitespace ...                    80 chars |

Here is what I get instead:

    Long text goes here ...                    80 chars |
<- whitespace preserved ...                    80 chars |
<- still whitespace ...                        80 chars |

Is there a way to reflow the text while preserving the left whitespace?

1
  • Not directly an answer to your question, but you might still want to look at par. Absolutely outstanding in my experience, provided that you take your time to digest the manual.
    – lcd047
    Apr 20, 2015 at 18:39

1 Answer 1

3

:set autoindent will ensure that new lines have the same indentation as the previous line. This will also happen when you hit enter in insert mode (or any other time you add a new line, like o/O).

Note that this is a local setting, so it would have to be set in each buffer you want this to happen in. To get around this, you can use autocmds or filetype files so that the setting is applied whenever you open a new buffer with a certain filetype.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.