I have the following custom object defined to allow selecting function calls: map global object f 'c[\w\.]+\(,\)<ret>'. However, there are a few gotchas that make it not that pleasant to use. Would love to learn more about whether these are expected behavior and how to work around them.
<a-a>f will not work if my cursor is on the “begin” part of the custom object. It will work if it’s on the “end” though. E.g. fo|o(bar) won’t work.
<a-.> works for <a-a>, but not <a-i>.
I have done some testing and I can confirm (1), although (2) seems to work on my side with both a-a and a-i, provided the cursor is positioned correctly.
About (1): the use case for c regex,regex object selection seems to be that your cursor should start between the opening and the closing regex, not at the beginning or the end. The behavior you observe seems to be the expected one.
In your use case, perhaps it would better not to rely on c object selection, but to define your own mapping starting with the user/leader key (which is space). The key sequence you define, space f, could call a key sequence that extends to the end of a regex that specifies …(…), assuming your cursor is positioned on the first character of the function call. Alternatively, the key sequence you define could call a custom command with try %{…} catch %{…} blocks testing for an opening regex on the left and a closing regex on the right.
In any case, it seems that c object selection does not serve you well.
1 Like
Yeah it just seemed inconsistent since this isn’t the case for the built-in objects such as (, but oh well!