sponsor Vim development Vim logo Vim Book Ad

AutoClose : Inserts matching bracket, paren, brace or quote

 script karma  Rating 1429/545, Downloaded by 26063  Comments, bugs, improvements  Vim wiki

created by
Karl Guertin
 
script type
utility
 
description
There are very simple ways to insert a closing brace by setting up a few mappings. The problem with all these approaches is that they break undo, history or both. This script is my sixth attempt at correcting this problem and the first one that has worked in all scenarios.

Using this script, typing ``(`` will result in (|), where | is the cursor position and the double backticks are just marking input. Typing a ``)`` will move the cursor outside the parens. This moving outside works even in nested scenarios. Typing ``if(my_array['key`` results in if(my_array['key|']) and ``)`` gets you if(my_array['key'])|.

The paired characters are: [, (, {, ", '

If you like this script, you should also check out surround.vim
 
install details
 

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
autoclose.vim 1.2 2009-06-19 6.0 Karl Guertin Fixed all known bugs (finally). Typing a closing character will now consistently jump out of a match at all times.
autoclose.vim 1.1.2 2007-09-20 7.0 Karl Guertin Fixes a rather nasty bug that sometimes deletes closing chars on the same line. Add double brace auto-indent. 1.1.2 contains fixes for a mapping typo and auto-indent edge case.
autoclose.vim 1.0.1 2007-04-03 7.0 Karl Guertin Knew I shouldn't have uploaded the first version as 1.0
ip used for rating: 44.206.248.122

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