Hi Vim users.

I have a question: Given a standard function call block of text:

func(arg1, arg2, arg3);

how do people here deal with editing the argument list efficiently?

I'm looking to try to create a custom motion to allow me to move
across and change arguments with a minimum number of keystrokes, as I
find myself doing that a fair bit. This is what I quickly came up with
(it's buggy - I don't deal with many cases here)

/\((\zs.\)\|\(,\zs.\)\|\()\)

which puts search marks here:

func(_arg1,_ arg2,_ arg3_);

I can then use n as a motion to get around the function call (more or
less) and even do things like dnnp to swap an argument with the next
one in the list (sometimes it even finishes up with the correct
syntax!).

Before I spend too much time sorting out the search term to work in
more cases, I was wondering if anyone else had already dealt with
this, or if anyone has other ideas about how to accomplish editing a
list as a list.

Ideally I'd like to be able to mutate the yanked text to fit in with
its new placement within a list (move the comma to the start or end if
putting before or after a parenthesis) and also to create a command
which behaves like ciw for arguments... This seems to be beyond me,
though. I can't even work out how to create a custom motion.

Cheers.
Tom.

Reply via email to