I recently started using treesit and I'm noticing with C files, my auto-indent is 2 spaces. How can I fix this to make it 4 spaces again? I've tried c-basic-offset.

1 Answer 1


You are probably in c-ts-mode, so the correct variable is c-ts-mode-indent-offset. c-basic-offset is only for buffers that are in c-mode.

  • Is there a way to make it guess the offset of the buffer so it doesn't have to reformat? Commented Dec 24, 2023 at 7:02
  • Not that I know of. You would probably have to write that yourself if you really want it. It is probably better to use directory–local variables.
    – db48x
    Commented Dec 24, 2023 at 7:13
  • How do you mean directory local? Commented Dec 24, 2023 at 7:44
  • I mean that you can give a variable like c-ts-mode-indent-offset a different value for files in different directories. Search for it, it’s in the Emacs manual (C-h i).
    – db48x
    Commented Dec 24, 2023 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.