So, I really like the Jupyter notebook (formerly known as the IPython notebook), but I often find myself missing the ‘fancy’ features that ‘proper’ editors have. I particularly miss the amazing multiple cursor functionality of editors like Sublime Text and Atom.
因此,我真的很喜欢Jupyter笔记本(以前称为IPython笔记本),但是我经常发现自己缺少“适当”编辑者具有的“精美”功能。 我尤其想念Sublime Text和Atom之类的编辑器惊人的多光标功能。
I’ve known for a while that you can edit a cell in your default $EDITOR
by running %%edit
at the top of the cell – but I’ve recently found out that you can configure Jupyter to use Sublime Text-style keyboard shortcuts when editing cells in the notebook – all thanks to CodeMirror, the javascript-based text editor component that the Jupyter notebook uses. Brilliantly, this also brings with it the multiple-cursor functionality! So, you can get something like this:
我已经知道一段时间了,您可以通过在单元格顶部运行%%edit
默认$EDITOR
中的单元格-但是我最近发现您可以将Jupyter配置为使用Sublime Text样式的键盘快捷键在笔记本中编辑单元格时–多亏了CodeMirror ,Jupyter笔记本使用的基于JavaScript的文本编辑器组件。 出色的是,这还带来了多光标功能! 因此,您可以获得以下内容:
![IPyNbSublime](http://www.pybloggers.com/wp-content/uploads/2016/03/blog.rtwilson.comwp-contentuploads201603IPyNbSublime-c843895468322fa877908fee62800915ed61999c.gif)
So, how do you do this? It’s really simple.
那么,你如何做到这一点? 真的很简单。
- Find your Jupyter configuration folder by running
jupyter --config-dir
- Open the
custom.js
file in thecustom
sub-folder in your favourite editor - Add the following lines to the bottom of the file
- 通过运行
jupyter --config-dir
查找Jupyter配置文件夹 - 在您喜欢的编辑器中的
custom
子文件夹中打开custom.js
文件 - 将以下行添加到文件的底部
require(["codemirror/keymap/sublime", "notebook/js/cell", "base/js/namespace"],
function(sublime_keymap, cell, IPython) {
// setTimeout(function(){ // uncomment line to fake race-condition
cell.Cell.options_default.cm_config.keyMap = 'sublime';
var cells = IPython.notebook.get_cells();
for(var c=0; c< cells.length ; c++){
cells.code_mirror.setOption('keyMap', 'sublime');
}
// }, 1000)// uncomment line to fake race condition
}
);
翻译自: https://www.pybloggers.com/2016/03/how-to-get-sublime-text-style-editing-in-the-ipythonjupyter-notebook/