File: delim-col.el.html
delim-col helps to prettify columns in a text region or rectangle.
If you have, for example, the following columns:
a b c d
aaaa bb ccc ddddd
aaa bbb cccc dddd
aa bb ccccccc ddd
And the following settings:
(setq delimit-columns-str-before "[ ")
(setq delimit-columns-str-after " ]")
(setq delimit-columns-str-separator ", ")
(setq delimit-columns-before "")
(setq delimit-columns-after "")
(setq delimit-columns-separator "\\t")
(setq delimit-columns-format 'separator)
(setq delimit-columns-extra t)
If you select the lines above and type:
M-x delimit-columns-region RET
You obtain the following result:
[ a , b , c , d ]
[ aaaa, bb , ccc , ddddd ]
[ aaa , bbb, cccc , dddd ]
[ aa , bb , ccccccc, ddd ]
But if you select start from the very first b to the very last c and type:
M-x delimit-columns-rectangle RET
You obtain the following result:
a [ b , c ] d
aaaa [ bb , ccc ] ddddd
aaa [ bbb, cccc ] dddd
aa [ bb , ccccccc ] ddd
Now, if we change settings to:
(setq delimit-columns-before "<")
(setq delimit-columns-after ">")
For the delimit-columns-region example above, the result is:
[ <a> , <b> , <c> , <d> ]
[ <aaaa>, <bb> , <ccc> , <ddddd> ]
[ <aaa> , <bbb>, <cccc> , <dddd> ]
[ <aa> , <bb> , <ccccccc>, <ddd> ]
And for the delimit-columns-rectangle example above, the result is:
a [ <b> , <c> ] d
aaaa [ <bb> , <ccc> ] ddddd
aaa [ <bbb>, <cccc> ] dddd
aa [ <bb> , <ccccccc> ] ddd
Note that delimit-columns-region operates over the entire selected
text region, extending the region start to the beginning of line and
the region end to the end of line. While delimit-columns-rectangle
operates over the text rectangle selected which rectangle diagonal is
given by the region start and end.
See delimit-columns-format(var)/delimit-columns-format(fun) variable documentation for column formatting.
delimit-columns-region is useful when you have columns of text that
are not well aligned, like:
horse apple bus
dog pineapple car
porcupine strawberry airplane
delimit-columns-region and delimit-columns-rectangle handle lines
with different number of columns, like:
horse apple bus
dog pineapple car EXTRA
porcupine strawberry airplane
Use delimit-columns-customize to customize delim-col package variables.
Defined variables (10)
delimit-columns-after | Specify a string to be inserted after each column. |
delimit-columns-before | Specify a string to be inserted before each column. |
delimit-columns-end | Specify column number to end prettifying. |
delimit-columns-extra | Non-nil means that lines will have the same number of columns. |
delimit-columns-format | Specify how to format columns. |
delimit-columns-separator | Specify a regexp which separates each column. |
delimit-columns-start | Specify column number to start prettifying. |
delimit-columns-str-after | Specify a string to be inserted after all columns. |
delimit-columns-str-before | Specify a string to be inserted before all columns. |
delimit-columns-str-separator | Specify a string to be inserted between each column. |
Defined functions (7)
delimit-columns-customize | () |
delimit-columns-format | (SPACES) |
delimit-columns-rectangle | (START END) |
delimit-columns-rectangle-line | (STARTPOS &optional BEGEXTRA ENDEXTRA) |
delimit-columns-rectangle-max | (STARTPOS &optional BEGEXTRA ENDEXTRA) |
delimit-columns-region | (START END) |
delimit-columns-str | (STR) |