Common usage
Introduction
Tabular is a Vim script for text alignment.
- Tabular (github.com)
Tables
:Tab /|
Result
| Fruit | Color |
| ----- | ----- |
| Apple | Red |
| Banana | Yellow |
| Kiwi | Green |
See: Tabular help
Variables
Colons
:Tab /:\zs/l0l1
Result
title: "Hello world"
description: "This is a description"
src: "image.jpg"
height: 320
width: 640
See: Aligning colons
Tab command
Basic example
Right align
The \zs atom
:Tab /:\zs
Result
title: My picture
src: img.jpg
The \zs atom will exclude the : from the search match.
See: \zs atom
Specifier
:Tab /:/r1c1l0
Result
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
See: Specifiers
Regexp
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) |
See: Specifiers
Also see
- godlygeek/tabular (github.com)
- Aligning text with Tabular.vim (vimcasts.org)
0 Comments for this cheatsheet. Write yours!