When I write Python code, I personally prefer indenting with 4 spaces instead of a tab. However, in my day job I work with a codebase that uses only tabs.
When I open one of these files in emacs, tabs display eight spaces wide. I have tried adding both
(setq-default tab-width 4) and
(setq tab-width 4) to my init file, but neither of these seem to have any affect on this problem. I have used
whitespace-mode to confirm that it is indeed one tab that I am seeing and not two, and that they are indeed eight spaces wide. When I check the value of the variable
tab-width from whatever buffer I am having the problem in, I get the following message:
tab-width is a variable defined in `C source code'.
Its value is 8
Local in buffer <whateverbuffer>; global value is 4
I know that I want
Its value to be 4 instead of eight, but I have not had any luck setting it. Also, in the documentation it says of
Automatically becomes buffer-local when set...I have a feeling my problem stems from this, but I don't quite understand what this means. Any suggestions? Thank you!