VIM textwidth has no effect

前端 未结 7 1511
遥遥无期
遥遥无期 2021-02-01 17:19

This feels like a dumb question, but I can\'t find an answer on the Internet (or in VIM help). I\'m using VIM 7.2 on Mac OS X. All I want to do is wrap my lines at 72 characters

7条回答
  •  南方客
    南方客 (楼主)
    2021-02-01 17:53

    Try gggqGto apply the new text width to the whole buffer.

    • gg means : go to the beginning of buffer
    • gq means : reformat the text included in the motion
    • G means : go to the end of the buffer

    (It will works if the format options are correctly set, as detailed in Zyx post)

    On the other hand, you could also display your existing text with a width of 72 characters by adding a modeline at the beginning or end of your file. See :help modeline

    Something like vim:tw=72 should work.

提交回复
热议问题