Skip to content

Instantly share code, notes, and snippets.

@stuntgoat
Last active October 27, 2015 14:03
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stuntgoat/ee43f7e406f300237628 to your computer and use it in GitHub Desktop.
Save stuntgoat/ee43f7e406f300237628 to your computer and use it in GitHub Desktop.
// register a callback when the IPython.notebook instance is created.
$([IPython.events]).on('app_initialized.NotebookApp', function(){
function to(mode) {
// this can be either 'vim' or 'emacs'
var mode = mode || 'emacs';
// first let's apply mode to all current cells
function to_mode(c) { return c.code_mirror.setOption('keyMap', mode);};
var cells = IPython.notebook.get_cells();
if (cells != null) {
cells.map(to_mode);
}
// apply the mode to future cells created
IPython.Cell.options_default.cm_config.keyMap = mode;
};
require(["codemirror/keymap/emacs"],
function (_) {
if (IPython.notebook != undefined) {
to('emacs');
};
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment