How to get vim to format bulleted lists with correct indentation

被刻印的时光 ゝ 提交于 2019-12-04 19:23:19

问题


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.

回答1:


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.



来源:https://stackoverflow.com/questions/7282355/how-to-get-vim-to-format-bulleted-lists-with-correct-indentation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!