如何在Vim中以段落格式在一行中重新格式化"gq"ed文本

lcl*_*ltj 9 vim

我有一些以前使用"gggqG"在vim中格式化的文本文件.现在我需要将它们转换为每段格式一行.我之前看过一种方法(使用:g命令),但我已经忘记了.有谁知道?

DrA*_*rAl 13

我知道有两种方法:

后者的解释:

:%s        " Search and replace across the whole file
/          " Delimiter
.\zs\n\ze. " Look for a character either side of a new-line (so ignore blank lines).
           " The \zs and \ze make the replacement only replace the new-line character.
/ /        " Delimiters and replace the new-line with a space.
Run Code Online (Sandbox Code Playgroud)