I am trying to line up a text table using align-regexp. A table, before alignment, looks like this:
| Alpha | Bravo | Charlie |
|-------|-------|---------|
| Delta | Echo | Foxtrot |
| Golf | Hotel | India |
and after alignment should look like this:
| Alpha | Bravo | Charlie |
|-------|-------|---------|
| Delta | Echo | Foxtrot |
| Golf | Hotel | India |
The best result I've gotten is C-u M-x align-regexp
, then \(\s-*\)|
as regexp, then repeat throughout line. What I get is this:
| Alpha | Bravo | Charlie |
|------- |------- |--------- |
| Delta | Echo | Foxtrot |
| Golf | Hotel | India |
The pipes line up, but now it's indented some random number of spaces that seems to be dependent on the content of the table. The problem with this is that markdown, the format of the document, now treats it as code because its indented.
My quick, but tedious, fix is to un-indent it, but I'd like to find out the right incantation for align-regexp
to make this indentation work properly.