11

Emacs has Paredit which actively prevents you from typing unbalanced parentheses (short of C-Q ( to force-insert a literal one, or other craziness). Inserting an open paren also inserts a closing one. Backspacing over a paren either deletes both the opening and closing paren, or neither. There are shortcuts to wrap a bare word in new parens, kick a word out of currently enclosing parens, expand parens to slurp up more nearby words, and so on.

Something like

imap ( ()<Left>

can get you started in Vim. But what's the best way to emulate some of the other more powerful features of Paredit in Vim?

Brian Carper
  • 71,150
  • 28
  • 166
  • 168
  • This might help as well: http://www.vim.org/scripts/script.php?script_id=2009 And there is another script: http://www.vim.org/scripts/script.php?script_id=2373 HTH – Zsolt Botykai Jan 16 '09 at 20:53

2 Answers2

3

Tamas Kovacs has created a Vim paredit script similar to the Emacs version.

Jeremy
  • 22,188
  • 4
  • 68
  • 81
2

May I suggest my bracketing system?

NB: prefer to fetch it directly from the svn repository, the new version is much more easier to tune to our needs.

If you are interested in the details/do-it-yourself-way, have a look at the related tip on vim.wikia.

Luc Hermitte
  • 31,979
  • 7
  • 69
  • 83
  • Two things: is your plugin available via pathogen/vundle? And is it straightforward to use? Could you give an example of the difference of your system against say, the tip on vim.wikia? – Ehtesh Choudhury May 06 '11 at 08:16
  • I haven't tried pathogen nor vundle, so I can't tell. It's available as a vimball, through svn access, and I'll fix the vam attached file in the near future. It's easy to use and configure, see the configuration file given as example on googlecode. The installation however requires a library plugin. The tip is just low level stuff and a list of related plugins. The plugin does much more, see the features summarized list : http://code.google.com/p/lh-vim/wiki/lhBrackets#The_bracketing_subsystem. – Luc Hermitte May 06 '11 at 09:56