The other answers covered why this happens. Here's a nice way to work around it.
wellle/targets.vim. I just recently found this plugin, and I think it's extremely underrated. It provides a new text object: din(
Mnemonic: (d)elete (i)nside (n)ext "(". This is compatible with other operators and several different objects, such as an(
, in"
, il(
(inside last parenthesis)
It also overrides the default behavior of i(
so that it first looks to see if the cursor is in parentheses, and then if it isn't it works the same way as in(
. This behavior can be turned on or off. For example:
def foo(bar):
^cursor here
Typing ci(
acts the same as cin(
, since the cursor is not in parentheses.
def foo( ):
^Cursor here, and in insert mode
This also accepts a count:
def foo(bar): #Define function foo(bar)
^cursor here
Typing c2in(
:
def foo(bar): #Define function foo( )
^cursor here
This also provides a new object, "argument". For example, dana
means "Delete around the next argument". This also accepts a count. For example:
def foo(arg1, arg2, BADarg3):
^ cursor here
Typing d3ana
:
def foo(arg1, arg2):
^ cursor here
There are many other features this plugin has, but these are the basic ones.