Search code examples
vimtabular

How to achieve this alignment with Taburalize in Vim?


So I have a code like this:

func "abc","def"
func "a little long",     {a: "string"}
func "hello", ["a", "b", "c"]

And I want this to align as:

func           "abc", "def"
func "a little long", {a: "string"}
func         "hello", ["a", "b", "c"]

I've been trying variations of :Tabularize /",\zs/, appending r0, r1, etc, but I don't have any idea of what I'm doing.

Any ideas?

If this can be done via some clean vimscript/macros, that would also be fine.


Solution

  • func |          "abc", |"def"
    func |"a little long", |{a: "string"}
    func |        "hello", |["a", "b", "c"]
    

    We want to select only the first "foo", of each line.

    :Tab /^func \zs"[^"]*",/l1r1