我有一些以前使用"gggqG"在vim中格式化的文本文件.现在我需要将它们转换为每段格式一行.我之前看过一种方法(使用:g命令),但我已经忘记了.有谁知道?
DrA*_*rAl 13
我知道有两种方法:
将textwidth设置为大并重新格式化:
:set tw=1000000
gggqG
Run Code Online (Sandbox Code Playgroud)使用替代(如果你想在映射中这样做,这更合适):
:%s/.\zs\n\ze./ /
Run Code Online (Sandbox Code Playgroud)后者的解释:
:%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)