skypacer210 / vim

Automatically exported from code.google.com/p/vim
0 stars 0 forks source link

`cib` doesn't work at the start of a line, while `ci'` does #118

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Be in normal mode editing the line "this is (a test)", with your cursor at 
the start of the line
2. type `cib` or `ci(` from normal mode

What is the expected output? What do you see instead?
I should be in insert mode with my cursor right after the (now empty) parens, 
like this: "this is (|)" where '|' is the cursor

Please provide any additional information below.
I'm not sure if this wasn't implemented because parens and braces sometimes 
span multiple lines, but `ci'` doesn't work on multiple lines, and I don't 
think it really has to, but I would like this to work for other text objects.  
I'll see if I can't whip up a patch, but don't hold your breath because I 
haven't done C in awhile!

Original issue reported on code.google.com by randomen...@gmail.com on 8 Mar 2013 at 5:25

GoogleCodeExporter commented 9 years ago
This is intentional. It's no just about multiple lines, it's about nesting. 
Consider

1. if (
2.   a &&
3.   (b || c) &&
4.   d)

If you place the cursor at the beginning of line 3, vab will select text on all 
four lines, because the cursor is immediately inside the parenthesis block 
starting at line 1 and ending at line 4. If your suggestion is implemented, 
only "(b || c)" on line 3 would be selected. This would break things in 
annoying and unexpected ways for things like =ab in C code.

Original comment by fritzoph...@gmail.com on 8 Mar 2013 at 6:11

GoogleCodeExporter commented 9 years ago
Gotcha.  I guess I'm not acquainted with the internals of how textobjects work, 
so I didn't think about how it might break other features.  Thanks for the 
info, feel free to close :)

Original comment by randomen...@gmail.com on 8 Mar 2013 at 11:41

GoogleCodeExporter commented 9 years ago

Original comment by lech.lor...@gmail.com on 9 Mar 2013 at 12:43