Babak K. Shandiz
Babak K. Shandiz's Blog

Babak K. Shandiz's Blog

IPython with Vim shortcuts [RE#7]

Babak K. Shandiz's photo
Babak K. Shandiz
·Aug 27, 2021·

1 min read

If you’re a Vim fan like me, probably you’ve already set your shell editor mode on vi by appending this line to ~/.bashrc (or for ZSH users, like me, ~/.zshrc):

set -o vi

But not all editors take this setup into account. One of the most revered REPL environments for Python people is IPython. The good news is IPython lets you opt to vi shortcuts by just running it like this:

ipython --TerminalInteractiveShell.editing_mode=vi

(Thanks to imiric for this great answer.)

If you’re using IPython as Django shell or you just want to make the setup above as a persistent default, open ~/.ipython/profile_default/ipython_config.py (if it was already there, otherwise read on), look for c.TerminalInteractiveShell.editing_mode parameter and set it like this:

c.TerminalInteractiveShell.editing_mode = 'vi'

If you couldn’t find the file don’t attempt to create it by yourself. Just create it with this shell command:

ipython profile create

About Regular Encounters
I’ve decided to record my daily encounters with professional issues on a somewhat regular basis. Not all of them are equally important/unique/intricate, but are indeed practical, real, and of course, textually minimal.

 
Share this