一段时间后如何使Vim的J和gq命令使用一个空格?


101

当我使用Vim的J命令时,大多数行都用一个空格填充。但是一段时间之后,Vim总是使用两个空格。请看以下示例:

This ends with a comma,
but this ends with a period.
Join with 'J' and what do you get?

对我来说,结果是:

This ends with a comma, but this ends with a period.  Join with 'J' and what do you get?

逗号后一个空格,句点后两个空格。如果您使用gq命令。

是否可以修改设置以使Vim在句点之后仅使用一个空格?


1
有谁了解这种违约的理由?
西罗Santilli郝海东冠状病六四事件法轮功2014年


5
@DenilsonSá:tldr; 在过去被认为是最佳实践的句子之间放置两个空格,但有些人还是这样。
Flimm 2014年

Answers:


106
:help joinspaces


'joinspaces' 'js'    boolean    (default on)
            global
            {not in Vi}
    Insert two spaces after a '.', '?' and '!' with a join command.
    When 'cpoptions' includes the 'j' flag, only do this after a '.'.
    Otherwise only one space is inserted.
    NOTE: This option is set when 'compatible' is set.

所以,你会做一个

:set nojoinspaces

获得您想要的东西。

或者,您可以使用

:set joinspaces!


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.