Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vi shortcuts in ipython notebook

I use ipython notebooks heavily to prototype ideas and build up code line by line, and I'd really like to be able to use vi shortcuts intracell. It seem like ipython notebook ships with functionality which simply needs to be enabled, though a couple options I've found don't seem to work:

http://www.borsuk.org/2014/07/20/ipython-notebook-vim-keys/ http://spaceli.wordpress.com/2013/10/04/add-vim-key-bindings-for-ipython-1-0-0/

I've also tried ivanov's vimception which works keybinding-wise but also breaks syntax highlighting among other things, and above all doesn't seem necessary if ipython ships with codemirror etc.

like image 920
rump roast Avatar asked Sep 08 '14 18:09

rump roast


People also ask

How do I add a shortcut to a notebook in Jupyter?

Starting with Jupyter Notebook 5.0, you can customize the command mode shortcuts from within the Notebook Application itself. Head to the ``Help`` menu and select the ``Edit keyboard Shortcuts`` item. A dialog will guide you through the process of adding custom keyboard shortcuts.


1 Answers

EDIT: This works much better than vimception: https://github.com/lambdalisue/jupyter-vim-binding


After a bit more research and more messing around, ivanov's vimception can be made to work pretty well.

https://github.com/ivanov/ipython-vimception

To fix the syntax highlighting, comment out line 346 in vimception.js. https://github.com/ivanov/ipython-vimception/issues/7

Also, using the %load_ext vimception does not allow one to turn vimception off, so instead just paste in the javascript as mentioned in the vimception readme.

Finally, vimception highlights the entire line in white making the text hard to read with a dark theme. This can be disabled leaving only a cursor by changing styleActiveLine line 209 in vimception.js to false.

209 cm.setOption('styleActiveLine', false);

really nice way to use python!

like image 134
rump roast Avatar answered Sep 20 '22 18:09

rump roast