Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Vi Keys in a Jupyter Console

I would like to know how to use vi-like key bindings in a Jupyter console -- not just with ipython, but with any kernel.

Previous answers show this is possible for ipython. So, perhaps there is some flag or config file where this can be specified. Jupyter does not appear to have an equivalent to ipython profile and giving the same flagged variables as in ipython does not work.

like image 207
Joe Shields Avatar asked Jan 02 '18 19:01

Joe Shields


People also ask

Does Jupyter notebook have a console?

To open a console panel, right-click a notebook and select "New console for notebook". JupyterLab supports action run-in-console which sends the current statement or selected text to console panel for execution.

What is Python console in Jupyter?

Code consoles enable you to run code interactively in a kernel. The cells of a code console show the order in which code was executed in the kernel, as opposed to the explicit ordering of cells in a notebook document. Code consoles also display rich output, just like notebook cells.

How do I configure IPython?

The IPython directoryIPython stores its files—config, command history and extensions—in the directory ~/. ipython/ by default. If set, this environment variable should be the path to a directory, which IPython will use for user data. IPython will create it if it does not exist.


1 Answers

The Jupyter console documentation almost provides the answer. For the flag, you just need to change the variable name:

jupyter console --kernel=ir --ZMQTerminalInteractiveShell.editing_mode=vi

To set this option globally, you have to add c.ZMQTerminalInteractiveShell.editing_mode='vi' to $HOME/.jupyter/jupyter_console_config.py. It's necessary to prefix the 'c.', similar to what's created when running ipython profile create, which the documentation does not specify.

like image 197
Joe Shields Avatar answered Oct 11 '22 07:10

Joe Shields