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

nel*_*rom 90 vim formatting

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

This ends with a comma,
but this ends with a period.
Join with 'J' and what do you get?
Run Code Online (Sandbox Code Playgroud)

对我来说,结果是:

This ends with a comma, but this ends with a period.  Join with 'J' and what do you get?
Run Code Online (Sandbox Code Playgroud)

逗号后面有一个空格,后面有两个空格.如果使用gq命令重新格式化段落,则会出现同样的情况.

是否有一个我可以修改的设置,使Vim在这段时间后只使用一个空格?

Ren*_*ger 97

: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.
Run Code Online (Sandbox Code Playgroud)

所以,你会做一个

:set nojoinspaces
Run Code Online (Sandbox Code Playgroud)

获得你想要的东西.

或者,您可以使用切换设置

:set joinspaces!
Run Code Online (Sandbox Code Playgroud)


Kev*_*ent 25

你需要:set nojoinspaces摆脱双重空间. 文档在这里

  • 或在.vimrc中:省略前导冒号:`set nojoinspaces` (2认同)

Luc*_*tte 10

:h 'joinspaces'
Run Code Online (Sandbox Code Playgroud)

将此选项设置为0/false/no.