[IPython-user] How to configure indent & unindent keystrokes for pyreadline under Windows XP?

TP wingusr@gmail....
Sun Feb 21 10:30:06 CST 2010

I'm using Windows XP, IPython 0.10, Python 2.6.4, pyreadline from


    Adding the following lines to your .inputrc file can make
    indenting/unindenting more convenient (M-i indents, M-u

    $if Python
    "\M-i": "    "
    "\M-u": "\d\d\d\d"

I put that in my .inputrc in the directory pointed at by my HOME
directory (also used by emacs which is why I have it), but nothing
changed. Presumably because pyreadline on Windows XP uses
%HOME%\pyreadlineconfig.ini instead.

Inside ~/_ipython/ipythonrc.ini, I see:

    readline_parse_and_bind "\M-i": "    "
    readline_parse_and_bind "\M-o": "\d\d\d\d"
    readline_parse_and_bind "\M-I": "\d\d\d\d"

But that's in a section that starts off with the comment "readline is
not available for MS-Windows", so I guess it doesn't apply.

My question is how do you change pyreadlineconfig.ini to bind Meta+i
(really Alt+i) to insert 4 spaces, and Meta-u (alt+u) to delete 4
previous characters?

It looks to me like bind_key() can only bind a key to a method call?

I don't see how to pass numeric args to readline ala emacs (which
would be a temporary workaround). Doing Meta+4 backspace for example,
doesn't do 4 backspaces.

Also, tabbing while trying to enter multi-line code acts a bit weird?
It displays all the matching files in the current directory, and then
inserts a hard tab?

Shouldn't <tab> and Shift+tab really be used there to indent/unindent?
I guess what I want is for pyreadline to somehow detect when you are
in the middle on entering multi-line code and act differently.

More information about the IPython-user mailing list