targets.vim
targets.vim copied to clipboard
Absolut position of text objects
Right now we can do "change 1,2,3 previous/next text object". Would it be possible to achieve an absolute reference instead of a relative one, so : "change 1st, 2nd, 3rd, .. text object".
So we could do something like:
function
c2a: "change 2nd argument" Achieving the same result in both cases.
This is currently not supported, but an interesting idea. Thanks for bringing it up 👍
Some quick comments on the suggestion:
-
c2a
conflicts with word objectsc2aw
,c2aa
,c2ab
etc. as it's a prefix. - It's not clear if
c2a
would mean to change inner argument etc. - Even the longer form
c2aa
is already used, for nested arguments, see https://github.com/wellle/targets.vim/blob/master/cheatsheet.md#argument-mappings.
So in order to add absolute positioning we'd need a different syntax, something like ci2fa
(change in second "first" argument for example). But even then it's not clear how you could use this in nested args.
You are right, I like your proposal ci2fa
would also allow ci2la
(change in second last argument). Not sure how to solve the nesting problem, I would propose that it works within the outer level if you are outside, and within the current level if you are inside:
In the following example:
<cursor> fun (arg1, arg2, arg3(subarg_1, subarg_2))
doing cila
would change the last argument of fun
. iIaA
are still available to control the finer behavior.
fun (arg1, arg2, <insert cursor>)
If we would be inside fun, it would have the same effect:
fun (<cursor>arg1, arg2, arg3(subarg_1, subarg_2))
But if we would be inside arg3
:
fun (arg1, arg2, arg3(<cursor>subarg_1, subarg_2))
Then it would affect the last argument of arg3
:
fun (arg1, arg2, arg3(subarg_1, <insert cursor>))
I think the "change in first" and "change in last" syntax makes sense. It unfortunately clashes with my cil
(change in line), but I prioritize ease of mind rather than number of strokes, so I would consider fine to change that to cicl
(change in current line) for example.
Oh, I've just noticed that cil
also doesn't work with your default for previous. I personally don't like l
for previous and I use nN
(I think is consistent with vim's search behavior), but that would be a big philosophy change I guess.