msgbartop
by Brian Neal
msgbarbottom

30 Nov 09 Using the Python Shell in Vi Mode

The Python shell is an invaluable tool for trying things out and experimenting with the language. Wouldn’t it be great if you could use the Python shell in Vi mode? Much to my surprise, it turns out you can.

Python leverages the GNU Readline Library in its shell code. The Readline library is used in a number of open source projects, notably the BASH shell. The Readline library looks for a configuration file at startup in a number of places. On Unix-like operating systems, the configuration file can be found at ~/.inputrc and falls back to /etc/inputrc.

One line is all you need in your ~/.inputrc file:

set editing-mode vi

Unfortunately I don’t know how to make this work under Windows.

Tags: , ,

Comments are closed.