mowshowitz
mowshowitz

Reputation: 69

How can I prevent RStudio from turning my spaces into tabs? It seems to ignore my global options setting

I use spaces to indent but RStudio always converts spaces into tabs. This is even though I have the "Insert spaces for tab" global option selected. Drives me batty!

Here's my settings in case I'm overlooking something.

Thanks in advance!

Upvotes: 3

Views: 1486

Answers (1)

beandip
beandip

Reputation: 186

This was driving me nuts too. Here's what I found (works in Rstudio Version 1.1.383 on Windows).

  • Check "Insert spaces for tab" (You've done this)
  • Set "Tab width" to 1
  • Restart Rstudio

Do this in your Global options. If you are using a project, do it in your Project Options as well (as pointed out by mowshowitz).

To see what is going on, select Global Options > Code > Display > Show whitespace characters. If you have "Insert spaces for tab" checked, it appears to truly insert spaces, but it forces your cursor to treat one tab-width's worth of spaces as a single character in the editor. By setting Tab width to 1, you can get around this limitation.

Upvotes: 5

Related Questions