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

前端 未结 1 421
北海茫月
北海茫月 2021-01-20 09:46

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!

<
相关标签:
1条回答
  • 2021-01-20 10:31

    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.

    0 讨论(0)
提交回复
热议问题