New Textobj: item in list ","
gerazov opened this issue · comments
Textobj requested
Select item in a list of items separated with ,
and bound by brackets or newlines, e.g:
a = [1, 2, 3, 4]
b = [
1, 2, 3, 4
]
This is similar to argument, but argument is limited to ()
.
Inner/Outer Difference
Inner leaves the ,
Outer includes the preceding (following if first item) ,
Vimscript plugin already implementing the textobj
https://github.com/wellle/targets.vim
Filetypes
all
Checklist
- The textobj would be useful to more users than just me.
- There is no lua plugin already implementing the textobj in an adequate manner.
- I read the docs and there is no such textobj already.
In most languages (e.g., lua), you can use the argument textobj from treesitter-textobjects for that already. If your language does not support that, I think it'd make more sense to make a FR there instead of re-implementing the same textobj again here
Well not really, or at least as much as I know - the argument object works only for arguments in a function call, i.e. it'll work only if the items are bounded by ( )
and not in the case above.
as I said, is some languages like in lua, it also works for array elements. If it does not work in your language, it'd therefore make more sense to make a FR there instead of re-implementing the same textobj again here
Oh you're right - it does work 😅 my bad - I thought I tested it ...
It would be useful for pure text, e.g.
This is a list of items in: rst, md, txt, text, mail files.
Here the treesitter solution doesn't work. Also for comments in code scripts that list stuff.
Currently I have it working through https://github.com/wellle/targets.vim, it would nice to have it in a nvim plugin.
Like a sub-sentence? Hmm. I can see a lot of potential edge cases for this (where does the first element in the list start, what about decimal commas and thousand separators, etc.)
Could you open a new issue for it since it's somewhat different, and also detail how exactly such a text object should behave?