DEV Community

Babak K. Shandiz
Babak K. Shandiz

Posted on • Originally published at babakks.github.io on

IPython with Vim shortcuts [RE#7]

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

(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'
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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.

Discussion (0)