Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                

Common usage

Introduction

Tabular is a Vim script for text alignment.

Tables

:Tab /|

Result

| Fruit  | Color  |
| -----  | -----  |
| Apple  | Red    |
| Banana | Yellow |
| Kiwi   | Green  |

See: Tabular help

Variables

:Tab /=

Result

title = "Hello"
src   = "image.jpg"
width = 640

See: Aligning on =

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

:Tab /:

Result

title : My picture
src   : img.jpg

See: :Tab command

Right align

:Tab /:/r0

Result

title:My picture
  src:   img.jpg

See: Right alignment

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 space
  • c1 -- Center align the comma with 1 space
  • l0 -- Left align with 0 spaces

See: Specifiers

Regexp

:Tab /^[^,]*\zs,/r0

Result

abc,hello
  c,hi there
  a,yo

See: Alignment regexps

Specifiers

SpecifierDescription
r1c1l0multiple specifiers, one per column
(the separator counts as a column)
lNLeft-align (with N spaces padding)
rNRight-align (with N spaces padding)
cNCenter-align (with N spaces padding)

See: Specifiers

Also see

0 Comments for this cheatsheet. Write yours!