by asiachick · 4y ago · 0 comments
foo(aa, bb, c);
foo(d, ggg, hh);
foo(iiii, i, jjjj);
I want to do something to the 2nd argument on each line. add a fn(prevContents). So I search for "foo(" and then pick "put a cursor on every match". Then how do get to the first comma and the select to the second comma on each line? This is easy with vim, easy with keyboard macros, not easy with multiple cursors (that I know of). For example as soon as I press "find" so I can search for the comma I lose multiple cursors. Maybe there's a special "Search with multiple cursors" command but if so that just highlights the issue, you shouldn't need special commands, you should be able to combine existing commands. vim and keyboard macros make that easy. C-f, "foo\(" [open a Find dialog]
C-Enter: [foo(]XX, YY, ZZ); [Find All shortcut]
Right: foo(|XX, YY, ZZ); [move to the right side of the match]
C-Right: foo(XX|, YY, ZZ);
C-Right: foo(XX,| YY, ZZ);
C-Right: foo(XX, YY|, ZZ);
C-S-Left: foo(XX, [YY], ZZ); [select leftward]
I suppose that it's not quite as ergonomic as Vim keybindings, but it's definitely less of a departure from the usual OS text boxes.What I'd do is this: Put the cursor on one of the calls, then use ctrl-d to put a new cursor at all the matches. Then use ctrl-right-arrow to move by word until the second comma, combine that with shift to select the argument and edit all of them with visual feedback to my heart's content.
In reality, depending on the complexity of the text, after creating all the cursors, I'd probably use the vim movements to get them to where I need though.