Created
March 27, 2016 19:31
-
-
Save memeplex/c256c53a16c5a0187fd4 to your computer and use it in GitHub Desktop.
Jupyter notebook vim bindings: .ipython/profile_default/static/custom/custom.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
'base/js/namespace', | |
'base/js/events', | |
'jquery', | |
'codemirror/keymap/vim', | |
'codemirror/addon/dialog/dialog' | |
], function(IPython, events, $) { | |
events.on('app_initialized.NotebookApp', function() { | |
IPython.keyboard_manager.edit_shortcuts.remove_shortcut('esc'); | |
IPython.Cell.options_default.cm_config.vimMode = true; | |
// codemirror dialog for cmdline and search | |
$('head').append('<link rel="stylesheet" type="text/css" ' + | |
'href="/static/components/codemirror/addon/dialog/dialog.css">') | |
$('head').append('<style type="text/css">' + | |
'.CodeMirror-dialog {opacity: 0.9 !important;}</style>'); | |
// avoid ipython command mode while in codemirror dialog | |
var bind_events = IPython.Cell.prototype.bind_events; | |
IPython.Cell.prototype.bind_events = function () { | |
bind_events.apply(this); | |
if (!this.code_mirror) return; | |
var that = this; | |
this.code_mirror.on('blur', function() { | |
if ($('.CodeMirror-dialog').length > 0) | |
that.events.trigger('edit_mode.Cell', {cell: that}); | |
}); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment