StandardNerd
StandardNerd

Reputation: 4183

Vim Tabular plugin: align different characters (eg. <%=, TRUE, FALSE, ...) after Ruby Symbol

I have the following Ruby code snippet that I'd like to tabularize:

It's an YAML file:

<% 4.upto(100) do |i| %>
importtask_<%= i %>:
  scheduled_start: DateTime.now
  repetition_interval: <%= ['days', 'months', 'weeks'].sample %>
  num_repetition_intervals: <%= [*1..10].sample %>
  status: <%= [0..4].sample %>
  created_at: <%= Date.today.prev_month - i.days %>
  user_id: 1
  publish_after_import: TRUE
  ili_agg_config_id: 1
  replace_all: TRUE
  force_import: FALSE
  repeat_until: <%= Date.today.next_month + i*100.days %>
<% end %>

using

:Tab /<%=

I get all values starting with <%= aligned but of course the rest (Datetime, TRUE, FALSE) not:

    <% 4.upto(100) do |i| %>
    importtask_<%= i %>:
      scheduled_start: DateTime.now
      repetition_interval:          <%= ['days', 'months', 'weeks'].sample %>
      num_repetition_intervals:     <%= [*1..10].sample %>
      status:                       <%= [0..4].sample %>
      created_at:                   <%= Date.today.prev_month - i.days %>
      user_id: 1
      publish_after_import: TRUE
      ili_agg_config_id: 1
      replace_all: TRUE
      force_import: FALSE
      repeat_until:                 <%= Date.today.next_month + i*100.days %>
    <% end %>

How can I achieve to get

<% 4.upto(100) do |i| %>
importtask_<%= i %>:
  scheduled_start:              DateTime.now
  repetition_interval:          <%= ['days', 'months', 'weeks'].sample %>
  num_repetition_intervals:     <%= [*1..10].sample %>
  status:                       <%= [0..4].sample %>
  created_at:                   <%= Date.today.prev_month - i.days %>
  user_id:                      1
  publish_after_import:         TRUE
  ili_agg_config_id:            1
  replace_all:                  TRUE
  force_import:                 FALSE
  repeat_until:                 <%= Date.today.next_month + i*100.days %>
<% end %>

using Vim Tabular? Maybe there is an "align everything after : " regex for this?

Upvotes: 0

Views: 48

Answers (1)

StandardNerd
StandardNerd

Reputation: 4183

found it

:Tab /:\zs

does the trick!

just append \zs for "everything after :".

Upvotes: 0

Related Questions