sponsor Vim development Vim logo Vim Book Ad

vrackets : automatically close different kinds of brackets

 script karma  Rating 32/14, Downloaded by 1979  Comments, bugs, improvements  Vim wiki

created by
Gerardo Marset
 
script type
utility
 
description
Vrackets helps you a lot by auto-closing the brackets you type.
For instance, if you type "(", you get:
    (|)
("|" is the cursor.)
You can easily get out of the brackets by typing the closing bracket. If after that you type ")", you get:
    ()|
Lastly, brackets are auto-deleted if they are empty. For instance, if your screen looks like this:
    FooBar(|)
And you press backspace, you get this:
    FooBar|

By default it works for (), [], {}, "" and ''. It also works for ¡! and ¿?, for spanish speakers ;).
You can add more easily if you want (like <>, but I wouldn't recommend it unless for html/xml/etc).
 
install details
Download it and use :source path/to/the/script/vrackets.vim to try it.
If you want it to load automatically every time you start vim, put it in ~/.vim/plugin, or $HOME\vimfiles\plugin if you use Windows.
 

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
vrackets.vim 0.2.3 2011-10-27 7.0 Gerardo Marset Prevent annoyances by choosing a bit more smartly whether brackets should be auto-closed or not.
vrackets.vim 0.2.2 2011-08-31 7.0 Gerardo Marset Fixed a bug.
vrackets.vim 0.2.1 2011-08-31 7.0 Gerardo Marset Optimized the code a bit.
Also now the script won't modify the default register when deleting empty brackets.
vrackets.vim 0.2 2011-08-19 7.0 Gerardo Marset Added support for quotation marks and other pairs in which the opening symbol is the same as the closing one.
vrackets.vim 0.1.1 2011-07-06 7.0 Gerardo Marset Fixed a small bug.
vrackets.vim 0.1 2011-07-06 7.0 Gerardo Marset Initial upload
ip used for rating: 18.97.9.175

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