How to reformat “gq”ed text in one line per paragraph format in Vim

后端 未结 3 1850
感情败类
感情败类 2021-02-06 04:13

I have some text files previously formatted in vim using \"gggqG\". Now I need to convert them to one line per paragraph format. I saw a way(using :g command) to do that before,

3条回答
  •  别那么骄傲
    2021-02-06 04:51

    If your text paragraphs are separated by a blank line, this seems to work:

    :g!/^\s*$/normal vipJ
    

    :g global (multi-repeat)

    !/^\s*$/ match all lines except blank lines and those containing only whitespace.

    normal enters 'normal' mode

    vip visually select inner paragraph

    J join lines

提交回复
热议问题