4

Trying to beef up my regular python console, I wanted to add vi-style editing.

1st thing: python is not reading ~/.inputrc if I understand well.

Then, I tried to do (through ~/.pythonrc.py):

import readline
readline.parse_and_bind('set editing-mode vi')

Nothing's happening. Did I miss something? Or is it a problem with my terminal?

I'm on OS X using Terminal.app

(tried rlwrap with no success)

lajarre
  • 4,910
  • 6
  • 42
  • 69
  • Possible duplicate of: http://stackoverflow.com/questions/537522/standard-python-interpreter-has-a-vi-command-mode – arcseldon Nov 23 '15 at 23:50

1 Answers1

5

The readline modules in the Apple-supplied system Pythons in OS X do not link with the GNU readline library since Apple does not ship GNU readline with OS X (presumably because of license issues). They do link with the BSD editline library, libedit, which reads ~/.editrc and supports a different set of editing commands. See man 5 editrc for details. As documented here, you can check for the text libedit in readline.__doc__ to determine whether GNU readline or BSD editline is in use. If you really need GNU readline, you may be able to install the readline package from PyPI which has a pre-compiled version of the Python readline module linked with GNU readline.

Ned Deily
  • 83,389
  • 16
  • 128
  • 151
  • 3
    readline vs editline is the thing, thanks. Finally I'm just adding `bind -v` in ~/.editrc and I'm done – lajarre Apr 19 '13 at 01:08
  • I would recommend checking answers provided here - http://stackoverflow.com/questions/6636124/how-do-i-make-vi-editing-mode-work-in-irb-when-using-rvm – arcseldon Nov 24 '15 at 00:08