简体   繁体   中英

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.

<Up> / <CP> and <Down> / <CN> 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM