Vim has some very useful text motions such as ib, i), i}, etcetera to quickly select a portion of text. But, I often need an inner block in line-wise mode. For example (with line numbers):
1: $foo = array(
2: 'bar' => 'Bar',
3: 'quux' => 'Quux',
4: );
Now, when my cursor is on line 2 or 3 somewhere and I hit vib or vi), Vim selects line 2, 3 and the indenting spaces on line 4. I just want line 2 and 3. I have tried with Vib and Vi) but they do the same as with a lowercase v.
Is there any easy text motion or other quick way to select an inner block in line-wise mode?
I may get downvotes for this, but I'd just do an upward or downward motion the number of lines I need, like V3j or V2k as long as it's known.
I have a binding that switches between absolute and relative numbering (:set relativenumber
) so it's visually easy to identify as long as they're all on screen.
I agree that it would be nice to have the behaviour that you describe. If you're determined, then you could always roll your own custom text object using Kana's textobj-user framework. I used this to create a text object for working with ruby blocks, and found it surprisingly easy to do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With