By default Emacs uses tab instead of spaces for indentation, so I changed these 2 variables to change this behavior,
(setq-default indent-tabs-mode nil) ;; Disable indent with tabs
(setq default-tab-width 4) ;; Set default indent width
It did change the indent mode from tab to space, but if I press RET
, when I am in a programming buffer C++
for example, to enter a new line, I get 2 spaces of indentation instead of 4. How do I set this indentation level to 4 be default globally.
Also when when I am editing a line for example, it auto shift the line back to 2 space of indentation, for some reason, and also re-formats how I wrote the code, for example, I usually write like this,
if (true)
{
// 4 spaces for indentation.
}
If I try to edit or add something, it pushes the lines back to 2 spaces of indentation and also sometimes re-formats the brackets position,
if (true) {
// 2 spaces for indentation.
}
I am constantly fighting with this thing, and it gets annoying very quickly sometimes. As far as I know, I did not install any formatting package.