How can I make Vim's `J` and `gq` commands use one space after a period?

When I use Vim's J command, most lines are joined with a single space for padding. But after a period Vim always uses two spaces. Take the following example:

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

For me, the result is:

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

One space after the comma, two after the period. Same story if you reformat the paragraph with the gq command.

Is there a setting that I can modify to make Vim use only one space after the period?


: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.

So, you would do a

:set nojoinspaces

to obtain what you desire.

Alternatively, you can toggle the setting with

:set joinspaces!

You need to :set nojoinspaces to get rid of the double space. Documentation here


:h 'joinspaces'

Set this option to 0/false/no.