Putting the v in IPython: vim-ipython and ipython-vimception

Summary

This talk will explain how to intimately integrate IPython with your favorite text editor, as well as how to customize the IPython Notebook interface to behave in a way that makes sense to you. Though the concrete examples are centered around the world-view of a particular text editor, the content will be valuable to anyone wishing to extend and customize IPython for their own purposes.

Description

This talk will cover two projects: vim-ipython (1) and ipython-vimception (2)

1. Most people think of IPython as an application - but much of it is written as a library, making it possible to integrate with other tools.

vim-ipython is a Vim plugin that was first written during the sprints at SciPy 2011 as a two-way interface between the Vim text editor and a running IPython kernel. It turns vim into a frontend for IPython kernels, like the qtconsole and the notebook interface. It allows you to send lines or whole files for IPython to execute, and also get back object introspection and word completions in Vim, like what you get with: object?<enter> and object.<tab> in IPython. It currently has over 430 star gazers on GitHub. Because vim-ipython simply leverages much of existing IPython machinery, it allows users to interact with non-Python kernels (such as IJulia and IHaskell) in the same manner from the convenience of their favorite text editor. More recently, vim-ipython has gained the ability to conveniently view and edit IPython notebooks (.ipynb files) without a running an IPython Notebook server.

vim-ipython has a small and accessible code base (13 people have contributed patches to the project), which has frequently made it the reference example for how to implement and utilize the IPython messaging protocol that allows for the language-independent communication between frontends and kernels.

2. The IPython Notebook user interface has become highly customizable, and authoring code and content in the Notebook can be more pleasant and productive experience if you take the time to make it yours.

IPython 2.0 brings a modal notion to the Notebook interface. There are two modes: edit and mode command mode. In command mode, many single-key keyboard shortcuts are available. For example, m changes the current cell type to Markdown, a and b will insert a new cell above and below the current one, and so on. Edit mode removes these single key shortcuts so that new code and text can be typed in, but still retains a few familiar shortcuts, such as Ctrl-Enter, Alt-Enter, and Shift-Enter for cell execution (with some nuanced differences).

Part of the motivation behind the introduction of this modal interface was that performing operations on notebook cells became a tedious and awkward, as most operations required Ctrl-m to be typed too many times. For example, inserting 3 cells involved Ctrl-m a Ctrl-m a Ctrl-m a, whereas now it's just aaa in Command mode. But the other major reason for the modal refactor was to make it possible to add and remove shortcuts. For example, a user who finds it annoying that a stands for "insert above" and b for "insert below" and thinks that a for "insert after" and b for "insert before" makes more sense will now be able to make that change for herself.

Some of the keyboard shortcuts in command mode are already vi-like (j and k to move up and down between cells) but many are not, and a few are confusingly placed. ipython-vimception aims to be a reference implementation for how to perform shortcut and user interface customization in the notebook. In particular, along with vim-ipython's new ability to edit .ipynb files, ipython-vimception addresses the concerns of many die-hard vim aficionados. Many of them have otherwise shied away form the notebook interface as it offends their sensibilities for how text editing and document manipulation should be done. However, with the new customizable shortcut system in IPython, along with a vim emulation mode in cell text input areas, they finally will have a way to stay productive without having to change their ways.