Search code examples
vimneovim

Vim: delete inside matching delimiter as in Neovim


As a Neovim user, I am able to type di( (also di", di{ and so on) in order to delete the content delimited by matching brackets/quotes. For example, in a situation like the following

  (cursor here) 
 /
void foo(int bar)
-

By running di( I would get

          (cursor here) 
         /
void foo()
        -

And by running da( I would get

         (cursor here) 
        /
void foo
       -

However, in vim this behaviour can be accomplished only by placing the cursor on the starting bracket/quote first. So di( works only if the cursor is positioned as follows

          (cursor here) 
         /  
void foo(int bar)
        -

Because of that, in vim I have to run f(di( or F(di( according to where my cursor is on the line in order to move the cursor to the starting delimiter and, then, deleting the content. In neovim I can, instead, directly run di( obtaining the same result.

Is there any remap I can set in order to make vim behave like neovim does?


Solution

  • Vim used to treat nesting pairs (where the beginning and end are different) and non-nesting pairs (where the beginning and end are identical) differently but it all changed late in 8.2's lifecycle.

    Your Neovim build includes the patch but your Vim build doesn't.

    Update Vim to a version > 8.2.3255 and you will have the desired behavior.