Vim 表格插件:在 Ruby 符号之后对齐不同的字符(例如 <%=, TRUE, FALSE, ...)

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

我有以下 Ruby 代码片段,我想将其制成表格:

这是一个 YAML 文件:

<% 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 %>

使用

:Tab /<%=

我得到所有以 <%= 开头的值对齐,但当然其余的(日期时间、真、假)不是:

    <% 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 %>

我怎样才能得到

<% 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 %>

使用 Vim 表格?也许有一个 "align everything after : " 正则表达式?

找到了

:Tab /:\zs

成功了!

只需为 "everything after :" 添加 \zs。