This is my configuration in init.el for C/C++ code which is default value in linux kernel:
(setq indent-tabs-mode t)
I'm using this style and won't change it to
And indentation and alignment work perfectly when I'm writing C/C++ code.
But I found that when I try to manually align multiple lines of comments (comment at the end of a line) or macro, the
M-x align or
M-x align-regexp command will align them with tabs, sometimes tab+space, this is really annoying, since when I tried to view the file in other tools such as vim, less or in
git diff, the alignment will be messed up, and I work with other people, so I cannot change all the tool.
The easiest thing to do is to change Emacs
So how can I make
M-x align and
M-x align-regexp align all the multiple macros and comments with pure space instead tab (or tab+space)?
align-regexp, I enable
whitespace-mode to show the tab/space, you can see that all the blanks of the alignment of macros and comments are tabs instead spaces.(If the original block contains multiple spaces, it will be space+tab):
How can I modify
align-regexp or define a new function for both macros and comments of multiple lines?
I already come up a solution, it is not smart, but it is enough. If anyone got any better idea, welcome.