7

I want to wrap my text to 79 characters, I do that using the gq command. For most filetypes this works just fine and indents following lines.

With Markdown, however, it does the following:

enter image description here

enter image description here

The pattern seems to be that only the second line gets indented.

This is not really nice as it then parses differently. For reStructuredText (:set ft=rst) it works just fine with longer lines:

enter image description here

What would I have to do to get the same results in Markdown as in reStructuredText?

7
  • 2
    Have you got 'autoindent' set?
    – Antony
    Commented Sep 30, 2016 at 13:58
  • No, I have noautoindent. The funny thing is that once I do :set ft=rst and then :set ft=markdown, the gqip works as expected. It doesn't do before. So somehow back-and-forth in the filetype improves the situation. But either way I have noautoindent. Commented Sep 30, 2016 at 14:20
  • 1
    You need :set ai fo+=q and appropriate 'comments' for gq to make a hanging indent.
    – Antony
    Commented Sep 30, 2016 at 15:32
  • In both cases I have fo=tcq. And comments is fb:*,fb:-,fb:+,n:> before and after the rst-markdown switching. So I guess that is not the trick. Commented Sep 30, 2016 at 16:18
  • 2
    Okay, well try turning it on.
    – Antony
    Commented Sep 30, 2016 at 18:07

1 Answer 1

5

As far as I can tell (and from @Antony's comments), autoindent must be turned on for this to work. From the help pages:

When autoindent is on, formatting (with the "gq" command or when you reach 'textwidth' in Insert mode) uses the indentation of the first line.

…and, in practice, it works for me to reformat long list items.

Your Answer

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

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