4

Is there an option to automatically close brackets,quotes, parentheses etc in IPython?

I hoped there was a feature similar to that in the gedit plugin.

John
  • 41,131
  • 31
  • 82
  • 106

2 Answers2

3

if codemirror support it then it is probably possible by monkey-patch. Configurability is on it's way but long way to go. Patches welcomed.

Matt
  • 27,170
  • 6
  • 80
  • 74
3

It is possible to get apps (including IPython) that use readline to automatically add a closing parenthesis when an open parenthesis is typed by tweaking your ~/.inputrc, as suggested here, e.g. by adding: "(": "\C-v()\e[D"

Note that according to the creator of IPython automatic bracket matching can't be done in a plain readline-based application (i.e in a normal IPython terminal session). Though it's already part of the standard functionality of IPython's qtconsole (Although as commented below auto-closing of brackets is not currently possible).

Community
  • 1
  • 1
Pierz
  • 7,064
  • 52
  • 59
  • in qtconsole it doesn't work either typing f( doesn't auto add the closing bracket and move the cursor inb etween the brackets. Same thing with quotes. it doesn't autoclose and move the cursor. – MySchizoBuddy Jul 04 '13 at 13:56