Readline configuration

Discussion in 'Python' started by Mark Roach, Jan 1, 2005.

  1. Mark Roach

    Mark Roach Guest

    I have readline set up pretty much the same way as in the example in the
    python docs (http://docs.python.org/lib/readline-example.html) and
    something I find myself doing fairly often is

    type some code
    more code
    more code
    ...

    and then wanting to scroll back through the history to run the same code
    again after a module = reload(module). In Windows, this is pretty
    convenient as I can use up to move to point x in the history, press enter,
    and press down to move to point x+1 in history. Is there any way to get
    the same behavior with readline?

    It would be great to be able to ctrl+r <type part of first line> then just
    hit down+enter to reenter the rest of the code.

    Thanks,

    Mark
    Mark Roach, Jan 1, 2005
    #1
    1. Advertising

  2. Mark Roach wrote:

    > I have readline set up pretty much the same way as in the example in the
    > python docs (http://docs.python.org/lib/readline-example.html) and
    > something I find myself doing fairly often is
    >
    > type some code
    > more code
    > more code
    > ...
    >
    > and then wanting to scroll back through the history to run the same code
    > again after a module = reload(module). In Windows, this is pretty
    > convenient as I can use up to move to point x in the history, press enter,
    > and press down to move to point x+1 in history. Is there any way to get
    > the same behavior with readline?
    >
    > It would be great to be able to ctrl+r <type part of first line> then just
    > hit down+enter to reenter the rest of the code.


    See ipython (http://ipython.scipy.org). It provides mostly what you want:

    In [1]: for i in range(3):
    ...: print i,
    ...:
    0 1 2

    In [2]: print 'hello'
    hello

    In [3]: exec In[1]
    0 1 2

    Readline history search is bound to Ctrl-P/N (type a few characters, then hit
    Ctrl-P/N to get previous/next lines with those matching chars). Ctrl-r search
    is also configured by default.

    HTH,

    f
    Fernando Perez, Jan 5, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John C. Worsley
    Replies:
    0
    Views:
    1,388
    John C. Worsley
    Jan 21, 2004
  2. Mark
    Replies:
    0
    Views:
    797
  3. gavino
    Replies:
    4
    Views:
    528
    gavino
    Sep 20, 2010
  4. Jean-Michel
    Replies:
    0
    Views:
    350
    Jean-Michel
    Dec 22, 2007
  5. Andrew DeFaria
    Replies:
    1
    Views:
    196
    Ben Morrow
    Jan 30, 2008
Loading...

Share This Page