问题
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!
回答1:
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.
来源:https://stackoverflow.com/questions/48268178/how-can-i-prevent-rstudio-from-turning-my-spaces-into-tabs-it-seems-to-ignore-m