Examples

Bart Louwers edited this page Oct 19, 2015 · 16 revisions
Clone this wiki locally

Please contribute your examples by clicking edit!!

Simple expression

apple =   1==0
banana =100
 car = 2
  • =/f or =/lf or =/l1f or =/lf1 or =/l1f1 aligns only the first =
apple  = 1==0
banana = 100
car    = 2
  • (?<==)\s*./l1r0l0f1 aligns the first non-space character just after =
apple =  1==0
banana = 100
car =    2

Simple table

apple& orange &grapes
   one & two& three
  • & or &/l or &/l1 yields
apple & orange & grapes
one   & two    & three
  • &/c2l1 or &/c2l or &/(c2l)*3: two spaces after odd columns
apple  & orange  & grapes
 one   &  two    & three
  • &/llclr: each column has its own justification
apple & orange & grapes
one   &  two   &  three

Javascript object properties

var x = {
  foo: "hello",
  someLongProp: "some other value",
  x: { x: 12, y: 13 }
};
  • (?<=:) /l1l1f
var x = {
  foo:          "hello",
  someLongProp: "some other value",
  x:            { x: 12, y: 13 }
};

Features:

  • keeps : with the property name (required by JS)
  • does not change literal objects that appear as property values

Another Javascript example

var express = require('express'),
http = require('http'),
path = require('path'),
jadebrowser = require('jade-browser');

^\s*(?:var)?\s*\S|=/lr0llf2 yields

var express     = require('express'),
    http        = require('http'),
    path        = require('path'),
    jadebrowser = require('jade-browser');

CSS

-webkit-border-radius: 50%;
-moz-border-radius: 50%;
-ms-border-radius: 50%;
-o-border-radius: 50%;
border-radius: 50%;

:/r0cl

-webkit-border-radius: 50%;
   -moz-border-radius: 50%;
    -ms-border-radius: 50%;
     -o-border-radius: 50%;
        border-radius: 50%;

Ruby

Ruby DSL Statements with Options

  expose :id, :property, in: :summary, as: [:string]
  expose :account_id, :property, in: :summary, as: [:string]

(?<=:|,) /l0l1

  expose :id,         :property, in: :summary, as: [:string]
  expose :account_id, :property, in: :summary, as: [:string]

Ruby 1.9 Hash Syntax

{
  some: :value,
  fruit: "kumquat",
  animal: "dog",
  favourite_number: 17,
}

\w*:/lf1

{
  some:             :value,
  fruit:            "kumquat",
  animal:           "dog",
  favourite_number: 17,
}