I spent at least an hour trying to figure out how to change the number of spaces RStudio uses for a tab. To me using only 2 makes it extremely difficult to read the code. So after finally figuring it out, I decided to post this to save others the headache.
I've seen this question asked many times with various round about and strange answers but it turns out the answer is simple.
First go to "Tools">"Global Options"> on the side bar select "Code" and change "Tab Width"
THEN next is the step everyone is missing. The option above will be overwritten if you've already started the file. So next go to "Tools">"Project Options"> on the side bar select "Code Editing" and change "Tab Width" again. I'm not actually for sure the first step was needed but it may be because that's what I did.
Finally, you simply delete all the code and paste it, and it magically has the new number of spaces! Took me a long time to figure that out and was unable to find anything with such an easy solution, so I wrote this.
It is sometimes necessary to change the tab width to a different value, save the changes, and then re-set to the desired value. For example, I like 4 spaces. I changed to 5 and then back to 4 and that stuck.
© 2022 - 2024 — McMap. All rights reserved.