[IPython-dev] Adding emacs-style keybindings for Ctrl-A and Ctrl-E in notebook

Robert McGibbon rmcgibbo at gmail.com
Fri Mar 28 21:50:37 EDT 2014


I'm not sure if there's any more principled way to do this. There was some
discussion on github
a while ago about making the key bindings more configurable, but I'm not
sure exactly what got

Here's the hacky way I came up with to add a couple of CodeMirror's emacs
keybindings to
the notebook using custom.js, in case anyone else ways to use it. Just
sending it here for
googling / feedback.



// custom.js
"using strict";

$([IPython.events]).on('notebook_loaded.Notebook', function(){
    console.log('Adding emacs-style keybindings');
    var extraKeys = {'Ctrl-A': 'goLineStart', 'Ctrl-E': "goLineEnd"};

    for (var k in extraKeys) {
IPython.CodeCell.options_default.cm_config.extraKeys[k] = extraKeys[k];

    var cells = IPython.notebook.get_cells();
    var numCells = cells.length;
    for (var i = 0; i < numCells; i++) {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140328/34681692/attachment.html>

More information about the IPython-dev mailing list