{ "metadata": { "gist_id": "4cc9c3dd79d1c69a49c1", "name": "", "signature": "sha256:6123fbf4b9425ec36bf5ffc8f47a89fb6bd1f279654cd9fb280ddc874fc5dabe" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "
\n", " Putting \n", "
\n", "the \n", "
\n", "![](v.png)\n", "\n", "
\n", "in\n", "
\n", "IPython\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here's a link to the [abstract](https://conference.scipy.org/scipy2014/schedule/presentation/1715/) and you can [watch the video from SciPy 2014](https://www.youtube.com/watch?v=p9gnhmX1sPo) where this talk was presented. The rest of this document are the slides I used in the talk." ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "
\n", " Paul Ivanov\n", "\n", "

\n", "\n", "http://pirsquared.org\n", " \n", "\n", "

\n", "\n", " **@ivanov** on [Twitter](https://twitter.com/ivanov) and [GitHub](http://github.com/ivanov)\n", " \n", "
" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Fact:

\n", "

\n", "

\n", "80% of vi users simply don't know how to quit..." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Public Service Announcement:\n", "\n", "Press `Escape` a few times, then `:q!` to quit without saving. (save quit with `:wq`)\n", "\n", "\n", "



" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "



" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "



" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "



" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "



" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Summary of the talk:" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Build your own light saber!\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](files/yoda.jpg)\n", "\n", "Phrase lifted from an excellent talk by Sam Aaron\n", "\n", "[Zen and the Art of Live Programming](http://www.infoq.com/presentations/Live-Programming)\n", "\n", "(I got there via [this post from Tom Ballinger](http://ballingt.com/2013/12/21/bpython-curtsies.html), thanks Tom!)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "



" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "vim-ipython\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Two-way integration between vim and ipython.\n", "\n", "http://github.com/ivanov/vim-ipython" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "SciPy 2011" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](/files/scipy2011.jpg)\n", " " ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The way to get something done, sit down and talk during the sprints" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](/files/2011.jpg)" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "with the help of Min Ragan-Kelley" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](files/minrk.png)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Min also coined the #vimsorry hashtag for my tweets. Thanks Min!" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "\n", "\n", "
DEMO time!
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "



" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "



" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "



" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "



" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "



" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "



" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "How?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![protocol](files/protocol.png)" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Corrolary\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Vim does not need to be linked against the Python you use.\n", "\n", "The Python your Vim is linked against just needs IPython and PyZMQ installed into it." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "More details in this talk:\n", "\n", "**The IPython protocol, frontends and kernels. **\n", "\n", "Paul Ivanov and Thomas Kluyver, PyData SV 2014\n", "\n", "( [video](https://www.youtube.com/watch?v=QPimD4gL0ak) ) ( \n", "[slides](http://nbviewer.ipython.org/github/ipython/front-to-back/blob/master/Frontends.ipynb) )" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "bipython" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "http://bipython.org\n", " \n", "The powers of BPython and IPython, combined!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](http://bipython.org/images/bipython_screenshot.png)\n", "




\n", "\n", "
DEMO time!
\n", "\n", "




" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "ipython vimception" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "https://github.com/ivanov/ipython-vimception\n", "\n", "More vi keybindings and convention in the notebook.\n", "\n", "* gg and G to go to top and bottom of a notebook\n", "* :w to save\n", "* dd actually cuts (so you can `dd p` to cut and paste cells around)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We use CodeMirror in IPython. CodeMirror supports both `vim` and `emacs` keyboard shortcuts, but you have to enable them. \n", "Here's how you do that in the notebook." ] }, { "cell_type": "code", "collapsed": false, "input": [ "%%javascript\n", "// change the mode of all current and future CodeMirror instances\n", "function to(mode) {\n", " var mode = mode || 'vim'\n", " // first let's apply vim mode to all current cells\n", " function to_mode(c) { return c.code_mirror.setOption('keyMap', mode);};\n", " IPython.notebook.get_cells().map(to_mode);\n", " // apply the mode to future cells created\n", " IPython.Cell.options_default.cm_config.keyMap = mode;\n", "}\n", "\n", "require([\"components/codemirror/keymap/vim\"],\n", " function (vim) { \n", " to('vim'); \n", " console.log('vim.js loaded'); \n", " });" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "What's coming:\n", "\n", "vim-ipython:\n", " * editing notebooks (unmerged branch)\n", " * Python3 support (unmerged branch)\n", " * vim help (better docs) (PR Open)\n", "\n", "bipython:\n", " * kernel selection\n", " \n", "ipython-vimception:\n", "* multi-cell selection and manipulation (visual mode)\n", "* multi-level undo\n", "* other ideas?" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "So go forth and build your own lightsaber!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](files/saber.jpg)" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Emacs users?!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Sam Aaron's [Zen and the Art of Live Programming](http://www.infoq.com/presentations/Live-Programming)\n", "\n", "John Kitchin's [Emacs + org-mode + python in reproducible research](https://www.youtube.com/watch?v=1-dUkyn_fZA) (SciPy 2013)\n", "\n", "John has a dovetailing follow-up talk this year: \"A success story in using Python in a graduate chemical engineering course.\" This room 2:15 p.m.\u20132:45 p.m." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We use CodeMirror in IPython. CodeMirror supports both `vim` and `emacs` keyboard shortcuts, but you have to enable them. \n", "Here's how you do that in the notebook." ] }, { "cell_type": "code", "collapsed": false, "input": [ "%%javascript\n", "// change the mode of all current and future CodeMirror instances\n", "function to(mode) {\n", " var mode = mode || 'vim'\n", " // first let's apply vim mode to all current cells\n", " function to_mode(c) { return c.code_mirror.setOption('keyMap', mode);};\n", " IPython.notebook.get_cells().map(to_mode);\n", " // apply the mode to future cells created\n", " IPython.Cell.options_default.cm_config.keyMap = mode;\n", "}\n", "\n", "require([\"components/codemirror/keymap/emacs\"],\n", " function (emacs) { \n", " to('emacs'); \n", " console.log('emacs.js loaded'); \n", " });" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Then, for you, just put a call of: to('emacs') in that curly\n", "braces of that function (emacs) callback from earlier (that\n", "function's what will be called after the emacs.js file is\n", "actually loaded, because trying to call it before that won't\n", "work. So your solution should look something like this:" ] } ], "metadata": {} } ] }