There are facilities provided by emacs to align text, comments, assignments, or columns.
align-regexpcommands provided with emacs.
align.elextension written by Matthias Helmling. Do not confuse with the align.el lisp file provided with recent emacs versions and described above.
columnize-textcommand, which lines up words or numbers, either by rows or columns. This function is designed to be used manually when editing buffers.
letassignments in Lisp code. The align-let.el extension is written by Kevin Ryde.
Other ways to align text or figures
Tables can also be used to line up text. The extension
table.el, by Takaaki Ota is now available by default with emacs22.
Converting text to table gives access to a number of neat formatting features from TableMode. The next example is obtained by capturing a short text with
M-x table-capture, using space as the column delimiter and a newline as the row delimiter (the newline can be entered by hitting
C-q C-j or
C-o). The table is then removed with
M-x table-release, leaving the default left alignment.
+---------+--------+ Firstname Lastname |Firstname|Lastname| Firstname Lastname Alice Liddell => +---------+--------+ => Lewis Carroll |Alice |Liddell | Alice Liddell +---------+--------+ |Lewis |Carroll | Lewis Carroll +---------+--------+