开发者

How to get vim to format bulleted lists with correct indentation

In vim I can set the textwidth option and then new text is formatted to wrap. I can also use the "gq" command to explicitly wrap text. However, the behaviour with bulleted lists is a bit unexpected to me. The vim docs talk about using bulleted lists with hyphens for the bullets. When I try to do this, it starts okay:

- This is a bulleted list item that
  has been wrapped. It looks good.

However, if I continue onto a third line, it gives up on the indent:

- This is a bulleted list item that
  has been wrapped over more than
two lines. The indentation for lines
after the second is unexpected.

This happens with:

formatoptions=tcq
comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-

Just to be clear, I would like indentation like this:

- This is a bulleted list item that
  has been wrapped over开发者_如何学编程 more than
  two lines. I want every line after
  the first to get the same indent.


After further investigation, it looks like I just needed to do "set autoindent" to get the expected behaviour. This seems to work well both for wrapping of text as it it typed and wrapping with the "gq" command.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜