vim

Get matching parens in Vim


Is there a plugin that will help with matching parentheses in Vim? For example, in TextMate I can do something like this, where it will match parentheses:

enter image description here

If I type in ( it will automatically add in a matching parens, (), and if I type something in and accidentally re-type the closing parenthesis, it will ignore that. In other words, I could type in hello( or hello() and both would produce hello(). What would be the best way to do this in Vim?

Note: this is quite a bit more complex than just the ignoremap ( () for example.


Solution

  • I use delimitMate for this and it works great! It handles creating parens and curly braces for you and also allows you to type over the closing parens/brackets as you would expect.

    here are some installation instructions for common vim configurations if you would like to give it a try.