vim-easy-align icon indicating copy to clipboard operation
vim-easy-align copied to clipboard

Alignment of (Pandoc) markdown grid tables

Open robert-winkler opened this issue 2 years ago • 1 comments

Hi, the EasyAlign plugin saves me a lot of manual 'spaces' when creating tables. However, what can I do to correctly align the following table:

+-------------+----------------+--------------------------+-------------------+--------------------------+
| **Crop/**   | **Equipment**  | **Quality trait**        | **Statistical**   | **Reference**                  |
| **plant-**  |                |                          | **determination** |                                |
| **based**   |                |                          | **of biomarker**  |                                |
| **product** |                |                          |                   |                                |
+=============+=====+==========+==========================+===================+==========================+
| **Apple**   | GC-MS          | Post-storage changes,    | PCA-VIP scores    | [@rudell_prestorage_2008       |
|             | LC-UV/vis-MS   | metabolite levels        |                   |                                |
|             |                | associated with ethylene |                   |                                |
|             |                | synphesis, flavonoid     |                   |                                |
|             |                | pigment synphesis, and   |                   |                                |
|             |                | fruit texture            |                   |                                |
| +----------------+--------------------------+-------------------+--------------------------+
|             | UHPLC-DAD-HRMS | Post-harvest quality,    | PCA-VIP scores    | [@sun_composition_2017]        |
|             |                | post-harvest blue mold   |                   |                                |
|             |                | resistance               |                   |                                |
| +----------------+--------------------------+-------------------+--------------------------+
|             | ^1^H NMR       | Post-storage metabolite  | PCA-VIP scores    | [@brizzolara_metabolomics_2017 |
|             | GC-MS          | changes under low-oxygen | PLS               |                                |
|             | HS-SPME-GC-MS  | atmosphere storage       |                   |
+------------------+------------------+------------------+------------------+------------------+

The problem are the lines with | +----------------+--------------------------+-------------------+--------------------------+ The | are aligned with :EasyAlign *|; but the spaces of the 'incomplete' lines are removed. The result should look like:

+-------------+----------------+--------------------------+-------------------+---------------------------------+
| **Crop/**   | **Equipment**  | **Quality trait**        | **Statistical**   | **Reference**                   |
| **plant-**  |                |                          | **determination** |                                 |
| **based**   |                |                          | **of biomarker**  |                                 |
| **product** |                |                          |                   |                                 |
+=============+=====+==========+==========================+===================+=================================+
| **Apple**   | GC-MS          | Post-storage changes,    | PCA-VIP scores    | [@rudell_prestorage_2008]       |
|             | LC-UV/vis-MS   | metabolite levels        |                   |                                 |
|             |                | associated with ethylene |                   |                                 |
|             |                | synphesis, flavonoid     |                   |                                 |
|             |                | pigment synphesis, and   |                   |                                 |
|             |                | fruit texture            |                   |                                 |
|             +----------------+--------------------------+-------------------+---------------------------------+
|             | UHPLC-DAD-HRMS | Post-harvest quality,    | PCA-VIP scores    | [@sun_composition_2017]         |
|             |                | post-harvest blue mold   |                   |                                 |
|             |                | resistance               |                   |                                 |
|             +----------------+--------------------------+-------------------+---------------------------------+
|             | ^1^H NMR       | Post-storage metabolite  | PCA-VIP scores    | [@brizzolara_metabolomics_2017] |
|             | GC-MS          | changes under low-oxygen | PLS               |                                 |
|             | HS-SPME-GC-MS  | atmosphere storage       |                   |                                 |
+-------------+----------------+--------------------------+-------------------+---------------------------------+

I.e. I want to align the | and +; but the + according to the last column. Is this possible?

robert-winkler avatar Jan 11 '24 18:01 robert-winkler

Have you considered the dedicated https://github.com/dhruvasagar/vim-table-mode plug-in?

Konfekt avatar May 27 '24 12:05 Konfekt