简体   繁体   English

跳过长条目以在IPython 5.x中进行历史搜索

[英]Skipping long entries for history search in IPython 5.x

I use ipython console quite heavily for python workflow. 我在Python工作流程中大量使用ipython控制台。 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. 我对发布的新5.x系列感到非常满意,发现在历史记录搜索中,它能够在长代码块中自由导航,这是一把双刃剑。

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 : 例如,如果有一个最近导入的以导入foo开头的代码块,那么输入import f并按一下向上键以完成历史记录搜索现在会提示以下内容:

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. 现在,如果您只是在寻找一行导入语句,并且历史记录中的代码段足够长,那么在切换到历史记录中较早(所需)的import foo之前,有很多行需要向上导航。

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. 使用Ctrl+R浏览历史记录显然是解决此问题的方法,但是我想知道是否可以通过向上键使用它。

<Up> / <CP> and <Down> / <CN> iterate over every line in your history. <Up> / <CP><Down> / <CN>遍历历史记录的每一行。

Use <PageDown> and <PageUp> keys to iterate over entries instead. 使用<PageDown><PageUp>键可以遍历条目。

Here's a full list of shortcuts: http://ipython.readthedocs.io/en/stable/config/shortcuts/index.html . 以下是完整的快捷方式列表: http : //ipython.readthedocs.io/en/stable/config/shortcuts/index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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