Implement new textobject for indentation level #9843
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #1810.
Current Implementation
This implements a textobject corresponding to the current indentation level of the selection, bound on
i
. It is only implemented for the "match mode" (eg.mii
ormai
). It takes a count, where count extends the selection to further leftward indented surroundings than represented by the current selection.mai
will skip over empty lines to extend the selection, whereasmii
will stop on the first empty line above or below. Selection direction is preserved on extension.I've added as many tests as I could keep straight in my head. I almost feel like some sort of property testing might be better able to find the edge cases, but what is implemented is what I had time to think through.
Future Direction
I could implement "next" (
]i
) and "prev" ([i
) to be the next contiguous block of the same indentation level as the current selection, after one or more blank lines. However I don't want to hold this implementation back as it is now complete and I have little time to dedicate to further features. Others are welcome to implement, or I may return to it at a later date.