When using C++ mode I've noticed that the tab key indents the current line. However, if I'm at the end of the line, I would like to be able to use tab to add aligned whitespace so that I can add // comments without having to type many spaces manually.

I have tried adding a C++ mode hook with (setq c++-tab-always-indent nil) with no results. This is on Emacs 29.1

Is there a way to use tab to add whitespace to align a comment in C++ mode?


1 Answer 1


Solved this by using (setq-default c-tab-always-indent nil) on my init file.

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.