Tabular.vim : how to align on the first occurrence of 2 different delimiters placed at the beginning of Words?

谁说我不能喝 提交于 2019-11-30 09:57:03
Wouter J

Align on the first occurrence

The help file explains this problem, you can use this command:

:Tabularize /^[^@]*\zs@/l1l0

A little explaination:

  • ^ means the begin of the line
  • [^@]* match everything that isn't a @. The * means 0 or more times, as much as you can
  • \zs put the start of the regex here (everything from this point is matched)
  • @ the 'this point' in the previous sentence means the @ symbol
  • /l1l0 means align the 1st block to the left and add 1 space (l1) and align the 2nd block to the left and add 0 spaces (l0)

Align 2 different delimiters

You need to do this in 2 commands. To make your life easier you can name the pattern and use that name:

:AddTabularPattern f_at /^[^@]*\zs@/l1l0
:AddTabularPattern f_and /^[^&]*\zs&/l1l0

Now you can run

:Tabularize f_at
:Tabularize f_and

Map the commands

You can even map these methods to generate easy shortcuts. Read more about this here

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!