views:

457

answers:

3

I saw this somewhere, but cannot find it now. Is there a built-in function in emacs, or does someone have elisp, to line up all the equals signs in a series of inititialization statments in cc-mode?

Before:

int t=9;
Graphics g = new Graphics();
List<String> list = new List<String>();

After:

int          t    = 9;
Graphics     g    = new Graphics();
List<String> list = new List<String>();
+2  A: 

M-x align should do the trick.

Nathaniel Flath
+11  A: 

Use M-x align-regexp (here, M-x align-regexp RET = RET). You can also add an "alignment rule" to the variable align-rules-list, so that in future M-x align will do it. See the documentation (C-h f align) for details.

ShreevatsaR
Ok, I've bound this to C-x |. How did I use emacs for so long and not know about this? Thanks for the help.
Cheeso
A: 

WHy s this post tagged as beeing C#. This snipplet may be valid C++ as well...

because I program more in C# than C++, and because I ran out of tags.
Cheeso