Common usage
Tables
:Tab /|
| Fruit | Color |
| ----- | ----- |
| Apple | Red |
| Banana | Yellow |
| Kiwi | Green |
Variables
:Tab /=
title = "Hello"
src = "image.jpg"
width = 640
Colons
:Tab /:\zs/l0l1
title: "Hello world"
description: "This is a description"
src: "image.jpg"
height: 320
width: 640
Tab command
Basic example
:Tab /:
title : My picture
src : img.jpg
Right align
:Tab /:/r0
title:My picture
src: img.jpg
The \zs atom
:Tab /:\zs
title: My picture
src: img.jpg
The \zs
atom will exclude the :
from the search match.
Specifier
:Tab /:/r1c1l0
title : My picture
src : img.jpg
Explanation
r1
– Right align with 1 spacec1
– Center align the comma with 1 spacel0
– Left align with 0 spaces
Regexp
:Tab /^[^,]*\zs,/r0
abc,hello
c,hi there
a,yo
Specifiers
Specifier | Description |
---|---|
r1c1l0 |
multiple specifiers, one per column (the separator counts as a column) |
lN |
Left-align (with N spaces padding) |
rN |
Right-align (with N spaces padding) |
cN |
Center-align (with N spaces padding) |
Also see
- godlygeek/tabular (github.com)
- Aligning text with Tabular.vim (vimcasts.org)