How do I use vi keys in ipython under *nix?
In case someone's wandering in here recently, IPython 5.0 switched from readline to prompt_toolkit, so an updated answer to this question is to pass an option:
$ ipython --TerminalInteractiveShell.editing_mode=vi
... or to set it globally in the profile configuration (~/.ipython/profile_default/ipython_config.py
; create it with ipython profile create
if you don't have it) with:
c.TerminalInteractiveShell.editing_mode = 'vi'
You can also interactively switch between Vi-mode and Emacs mode. According to the the readline docs to switch between them you are supposed to be able to use the M-C-j key combination but that only seems to allow me to switch to vi-mode - on my Mac (where ESC is used as the 'Meta' key) it is: ESC+CTRL+j. To switch back to Emacs mode one can use C-e but that didn't appear to work for me - I had to instead do M-C-e - on my Mac it is: ESC+CTRL+e.
FYI my ~/.inputrc is set up as follows:
set meta-flag onset input-meta onset convert-meta offset output-meta on