{"id":299,"date":"2009-02-06T13:15:01","date_gmt":"2009-02-06T11:15:01","guid":{"rendered":"http:\/\/blog.louic.nl\/?p=299"},"modified":"2012-03-20T17:33:22","modified_gmt":"2012-03-20T15:33:22","slug":"vertically-align-a-table-or-something-in-vim","status":"publish","type":"post","link":"https:\/\/blog.louic.nl\/?p=299","title":{"rendered":"Vertically align a table (or something) in vim"},"content":{"rendered":"<p>Just a short note to myself how to align a table in vim. I found the <a href=\"http:\/\/stackoverflow.com\/questions\/357824\/how-to-automatically-align-python-variable-assignment-lines-in-vim\">answer here<\/a>. We start with the following example, a part of a LateX table (that was generated with <a href=\"http:\/\/calc2latex.sourceforge.net\/\">an openoffice plugin<\/a>). But the columns (\"&amp;\" characters) are not aligned vertically, which is ugly.<\/p>\n<pre>\r\n      C1 & c3 & 0.30593 & C1 \\\\ \r\n      C1X & c3 & 0.13418 & C1X \\\\ \r\n      C2 & c3 & 0.08862 & C2 \\\\ \r\n      C2X & c3 & -0.08100 & C2X \\\\ \r\n<\/pre>\n<p>Of course, aligning the &amp; characters can easily be done automagically (and this time I did not even have to write the script myself!)<\/p>\n<ul>\n<li>download the <a href=\"http:\/\/www.vim.org\/scripts\/script.php?script_id=294\">vim Align plugin<\/a><\/li>\n<li>install it. details on how to install are on the plugin's page<\/li>\n<li>use it: select a block and type (in this case, we want to align the & character):<br \/>\n<code>:Align &amp;<\/code>\n<\/li>\n<li>watch the magic<\/li>\n<\/ul>\n<pre>\r\n      C1   & c3 & 0.30593  & C1 \\\\\r\n      C1X  & c3 & 0.13418  & C1X \\\\\r\n      C2   & c3 & 0.08862  & C2 \\\\\r\n      C2X  & c3 & -0.08100 & C2X \\\\\r\n<\/pre>\n<p>Actually, this was just an example. The Align package has a special command to align LaTeX tables, which also aligns the newine commands \\\\. Just type <code>\\tt<\/code> instead of <code>:Align &amp;<\/code>.<\/p>\n<p>(And in case you want to know: the table shows AMBER ff03 atom types and partial charges of an octylglucoside molecule, as calculated by AM1-BCC. But you are probably not interested :) )<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just a short note to myself how to align a table in vim. I found the answer here. We start with the following example, a part of a LateX table (that was generated with an openoffice plugin). But the columns &hellip; <a href=\"https:\/\/blog.louic.nl\/?p=299\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[43,33],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.louic.nl\/index.php?rest_route=\/wp\/v2\/posts\/299"}],"collection":[{"href":"https:\/\/blog.louic.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.louic.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.louic.nl\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.louic.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=299"}],"version-history":[{"count":23,"href":"https:\/\/blog.louic.nl\/index.php?rest_route=\/wp\/v2\/posts\/299\/revisions"}],"predecessor-version":[{"id":677,"href":"https:\/\/blog.louic.nl\/index.php?rest_route=\/wp\/v2\/posts\/299\/revisions\/677"}],"wp:attachment":[{"href":"https:\/\/blog.louic.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.louic.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.louic.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}