machakann / vim-sandwich

Set of operators and textobjects to search/select/edit sandwiched texts.
1.44k stars 37 forks source link

Text object for function arguments #88

Closed joshuali925 closed 4 years ago

joshuali925 commented 4 years ago

Is it possible to create a text object for function arguments similar to targets.vim?

If I just do this,

let g:sandwich#recipes = deepcopy(g:sandwich#default_recipes)
let g:sandwich#recipes += [{'buns': ['[\[{(,]', '[,\]})]'], 'input': ['a'], 'regex': 1}]

a cisa on (a|bc[0], def) would give me (|], def) instead of (|, def).

I'm not too familiar with vim regex. Is it possible to implement it or should I use targets.vim along with vim-sandwich?

machakann commented 4 years ago

I think this kind of problem is difficult to handle with regular expressions, especially if an argument includes separators inside parentheses like (abc(def, ghi), jkl), since regular expressions are not so good at handling nestings.

I expect it would be more satisfactory to use more particular plugins: targets.vim, vim-textobj-parameter, vim-swap.

joshuali925 commented 4 years ago

Got it. Thanks for the quick response.