I am using a VT100 terminal emulator on Linux. In bash, up and down arrows scroll through the last commands executed; they work as expected.
Previous (up arrow) and next (down arrow) commands are not interpreted in the Python command line interpreter. What kind of key mappings do I need to make this work?
Thank you.
To access previous commands, simply press the up arrow. This will give you the last command you typed in. Pressing it again will produce the command before that, and so on.
A command line interpreter allows the user to interact with a program using commands in the form of text lines. It was frequently used till the 1970's. However, in modern times many command line interpreters are replaced by graphical user interfaces and menu-driven interfaces.
By default, the keymappings are:
You can change it in Options -> Configure IDLE -> Keys -> "history-previous"
and "history-next"
respectively.
I think I've found the answer, assuming you have the GNU Readline library. (This does mean I was partially wrong about the base implementation using a Unix-style interface, as it only does that when GNU Readline [or a port, I guess] isn't available.)
http://docs.python.org/tutorial/interactive.html#history-substitution
History substitution works as follows. All non-empty input lines issued are saved in a history buffer, and when a new prompt is given you are positioned on a new line at the bottom of this buffer.
C-P
moves one line up (back) in the history buffer,C-N
moves one down. Any line in the history buffer can be edited; an asterisk appears in front of the prompt to mark a line as modified. Pressing the Return key passes the current line to the interpreter.C-R
starts an incremental reverse search;C-S
starts a forward search.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With