In VIM, how do I break one really long line into multiple lines?

前端 未结 11 556
刺人心
刺人心 2021-01-29 17:53

Say I have a super long line in the VIM editor (say around 300+ characters). How would I break that up into multiple lines so that the word boundaries roughly break at 80 chara

11条回答
  •  孤城傲影
    2021-01-29 18:12

    If you're on *nix you probably have fold available.

    Select the region you want using v, then you can break on spaces at width 80 using:

    !fold --spaces --width=80

    This is esentially the same as using gq.

    However, if you just want to break at character 80 and not be restricted to whitespaces you can use:

    !fold --width=80

    If you want it with one keystroke just set a mapping - I've used

    vmap !fold --width=80

提交回复
热议问题