sponsor Vim development Vim logo Vim Book Ad

KillBrackets : Removes matching brackets/parens. Very handy in LISP/Scheme

 script karma  Rating 27/9, Downloaded by 1499  Comments, bugs, improvements  Vim wiki

created by
Jonas Møller
 
script type
utility
 
description
This script adds a feature I've often missed when hacking away at some code in Vim.

I recommend adding a keybinding, such as "<Leader>) :Killbracks"
To use it, just place the cursor on top of either a closing or opening bracket while in normal mode (vim will highlight the other one) and either type ":Killbracks" or use the keybinding you just added.

Problems (IMPORTANT FOR LISP):
There are problems associated with parens and bracks inside of quotes messing with "the order of things." Killbrackets is set up to ignore everything within "double quotes"  and 'single quotes' but if you're programming in a language that uses 'single quotes' for something completely different (like in LISP) you might be in trouble, if you had something like '(LIST OF STUFF) in your program.
To fix this, you go into the "KillBrackets.vim" file and search for "QUOTES SETTINGS" then uncomment the behaviour you want, and comment the behaviour you don't want (explained a bit further in the source)
Note that if you are "(inside quotes)" or '(inside quotes)', KillBrackets will do it's magic perfectly if the parens inside of the quotes are correctly matched. But if you are outside of the quotes ("wasd)wasd") KillBrackets will ignore everything within the quotes and only kill the matching bracket on the outside, and you'll end up with "wasd)wasd".
 
install details
Linux/Mac/BSD:
        Put the "KillBrackets.vim" file inside ~/.vim/plugin/ and restart vim

Windows:
        Put the "KillBrackets.vim" file inside C:\Program Files (x86)\Vim\vim74\plugin (requires admin rights) and restart vim.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
KillBrackets.vim 1.0.1 2013-09-07 7.0 Jonas Møller Added license (MIT)
KillBrackets.vim 1.0 2013-09-06 7.0 Jonas Møller Initial upload
ip used for rating: 18.97.14.83

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github