Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skipping long entries for history search in IPython 5.x

I use ipython console quite heavily for python workflow. As happy as I am with the new 5.x series released, I find the ability to freely navigate inside the long code blocks a double-edged sword when it comes to history search.

For example, typing import f and hitting the up key for history search completion now prompts the following to appear if there was a recent pasted code block that started with importing foo:

In [100]: import foo
     ...:
     ...: # copy-pasted code block that shows up in history
     ...: for foobar in foo.bar:
     ...:     pass
     ...:

Now if you were simply looking for a one line import statement, and if the code snippet in history is sufficiently long, that's a lot of lines to navigate upwards before you can switch to an earlier (desired) import foo in history.

So my question is, is there a shortcut that allows to skip a long history entry to the previous one? Browsing history with Ctrl+R is an obvious workaround for this issue, but I'd like to know if there's a way to get it to work with the up key.

like image 401
Vlas Sokolov Avatar asked Oct 20 '25 21:10

Vlas Sokolov


1 Answers

<Up>/<C-P> and <Down>/<C-N> iterate over every line in your history.

Use <PageDown> and <PageUp> keys to iterate over entries instead.

Here's a full list of shortcuts: http://ipython.readthedocs.io/en/stable/config/shortcuts/index.html.

like image 105
skovorodkin Avatar answered Oct 23 '25 11:10

skovorodkin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!