vim tabular only on the first match on the line?

后端 未结 4 974
忘了有多久
忘了有多久 2020-12-31 06:32

I\'m trying to format some python code with the tabular.vim plugin. It\'s currently a sqlalchemy declarative class, and looks something like this:

id     =           


        
4条回答
  •  清酒与你
    2020-12-31 06:57

    You can use this command:

    :Tabularize /^[^=]*\zs=
    

    The pattern only matches the first =.


    You can add these two line to ~/.vim/after/plugin/TabularMaps.vim

    AddTabularPattern 1=    /^[^=]*\zs=
    AddTabularPattern 1==   /^[^=]*\zs=/r0c0l0
    

    Next time, simply run:

    :Tabularize 1=
    

    If you don't need spaces around =, run this:

    :Tabularize 1==
    

提交回复
热议问题