To reformat Markdown tables, I use the following sequence of external commands (e.g. after visually selecting my table lines):
:<,>! sed 's/[[:space:]]\{1,\}\|/\#\|/g'
:<,>! column -t -s '\#'
The first command prefixes each |
(Markdown column delimiter) with a #
.
The second command creates aligned columns using #
as delimiter and removes it.
I also managed to combine those in a single command:
:<,>! sed 's/[[:space:]]\{1,\}\|/\#\|/g' | column -t -s '\#'
Now, I would like to create the corresponding custom MDTableFormat
command somewhere in my vimrc
file:
command! -range MDTableFormat ...
but I can't find the proper syntax for this.