Unexpected double quotes in RStudio on Mac after selecting text

Extra quotation marks appear after pressing Space in RStudio on macOS

Hi everyone,

I recently switched from Windows to macOS and have encountered a strange issue with quotation marks in RStudio.

On Windows, I was used to working as follows whenever I needed to put quotation marks around an existing word:

  1. I select the word:
    test

  2. I press the quotation mark key (either single or double quotes), and RStudio automatically surrounds the selected word:
    "test"

  3. I then press the space bar, Enter, or type a comma, depending on what I am writing:
    "test",

This worked as expected on Windows.

However, on macOS, I am getting some unexpected behaviour. I follow exactly the same steps:

  1. Select:
    test

  2. Press the double-quote key:
    "test"

  3. Then, as soon as I press the space bar, two additional quotation marks appear:
    "test"""

The same kind of behaviour also occurs with single quotes.

I have already tried a couple of solutions suggested by ChatGPT, but neither solved the problem:

1. Disabling automatic closing in RStudio

I went to:

Tools > Global Options > Code > Editing

and disabled “Auto-close quotes and brackets”.

This did not solve the issue.

2. Changing the macOS keyboard settings

I also checked the keyboard/input settings in macOS, including disabling Smart Quotes and trying different keyboard layouts/input sources.

This did not solve the issue either.

Has anyone experienced this behaviour in RStudio on macOS? Is there another RStudio or macOS setting that could be causing the extra quotation marks to appear when I press Space?

Any suggestions would be greatly appreciated.