In Emacs' C++ mode, I sometimes accidentally introduced a tab where I should use four whitespaces instead to create indentations. Adjacent lines with mixed uses of tabs and spaces for indentations are shown to be aligned in C++ mode.
But when I open the C++ file thus created in another editor, for example in Eclipse CDT editor, it will show that the indentations of the lines mentioned above are not actually aligned, because of mixed uses of tabs and spaces.
This makes me realized that Emacs C++ mode is not actually a pure text editor. A tab is probably not shown as wide as four whitespaces, and that makes me add more or less tabs than I should for aligning with other lines' indentations.
In Emacs C++ mode, how can I avoid making such mistakes?
Thanks.
(setq-default indent-tabs-mode nil)
prevents usingTAB
for indenting. But it does not remove existingTAB
chars already in a file. For that you need to useC-x h M-x untabify
.