I've long been editing code in Vim 7.4 with matchit and matchparen plugins. In my old setup it was easy to delete { some string } by placing the cursor on the { and then use the d% command.

I've now moved to a new computer system (and new job) with a fresh install of Vim 8.2 and I believe I've got the same plugins, but now when I use the d% command, it keeps the closing }.

This change in behavior now makes editing my code much more cumbersome as I have to deal with the closing } (or [)\], etc]) separately.

Could someone who understands the plugins or key mapping please tell me how to get back to the behavior where the terminating character is also deleted (or selected/yanked/etc).

  • 2
    there is no vim 8.3... what version are you using exactly? – Mass Jul 11 at 1:05
  • 1
    Welcome to the forum! Using Vim 8.2, without any plugin, I get the behaviour you like. Have you tried with vim --clean(which will launch a bare vim instance) to make sure your config is not causing this issue? – Biggybi Jul 11 at 1:20
  • Welcome to Vi and Vim! You can use the :map % command to check whether you have % mapped by a plug-in or not and what it's mapped to. (Better yet, :verbose map % will also include the name of the file where it was defined.) I can't reproduce the issue you're reporting, either with matchit or without it... Haven't tried matchparen. But please check which one you're using first. – filbranden Jul 11 at 3:20
  • Note that you can use da{ to delete a block inside curly braces. And you can use that command anywhere inside the block, not only on top of the { itself. I'd be happy to turn these comments into an answer, but I wanted to be able to explain why you're seeing the behavior you're currently seeing... – filbranden Jul 11 at 3:22
  • 2
    this might be a matchit bug. If you can reproduce this with a minimal example, please open an issue here: github.com/chrisbra/matchit I'd like to have this fixed – Christian Brabandt Jul 11 at 17:14

Thank you to filbranden for expanding my Vim command library with the :map % and da{ / di{ commands - those will surely prove useful.

Using those commands, and some useful diff tools, I identified that I was using a badly obsolete version of matchit. Deleting my bad plugin, and following the instructions in :help matchit-install, I was able to correct my installation, and return to the expected behavior of d%


| improve this answer | |
  • Glad that you figured it out and thanks for looping back with the solution! – filbranden Jul 13 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.