ove*_*ink 55
我觉得这是你真正想要的: gJ
来自:h gJ:
gJ Join [count] lines, with a minimum of two lines.
Don't insert or remove any spaces. {not in Vi}
Run Code Online (Sandbox Code Playgroud)
如果您从终端复制了某些内容并将其作为一个大的矩形块粘贴到vim而不是单行,这很方便.
我通常在视觉模式下使用它.暮色的东西,gJ.
Cas*_*bel 31
格式化会破坏信息.有许多不同的文本块,一旦格式化,将产生相同的文本块.因此,没有先验知识(即撤消)就无法逆转操作.
未格式化的:
Unformatted text could start out as either all one line, or several, yet look the same when formatted.
Unformatted text could start out as either all one line, or several,
yet look the same when formatted.
Run Code Online (Sandbox Code Playgroud)
格式:
Unformatted text could start out as
either all one line, or several,
yet look the same when formatted.
Run Code Online (Sandbox Code Playgroud)
如果你想让你的段落全部在一行上,或者如果你可以通过一些手动摆弄,你可以使用J一起连接线.您可以使用可视模式J一次将命令应用于多个行,也许可以与ap或组合使用ip,例如vipJ.同样,您仍然会丢失一些信息 - 在换行符之前有多个空格,然后格式化将最终折叠为单个空格.(您实际上可以通过使用gJ而不是修改空格来加入J,但是在格式化时你已经丢失了它们)
如果你被句子之后的额外空格(以!,?或.结尾的行)所困扰,请关闭连接空间: set nojoinspaces
我想加入没有空格的行的简单解决方案是:
:j!
Run Code Online (Sandbox Code Playgroud)
随着!该连接不插入或删除任何空格.对于整个文件,请使用:%j!.
见::help :join.