Skip to content

Instantly share code, notes, and snippets.

@geecu
Created April 24, 2014 08:11
Show Gist options
  • Save geecu/11246062 to your computer and use it in GitHub Desktop.
Save geecu/11246062 to your computer and use it in GitHub Desktop.
enable vim mode for jsbin editors
var vimBinding = document.createElement('script');
vimBinding.setAttribute('src','https://raw.github.com/marijnh/CodeMirror/master/keymap/vim.js');
var mirrors = document.querySelectorAll('.CodeMirror');
// browser support for onload may be iffy ...
vimBinding.onload = function () {
Array.prototype.forEach.call(mirrors, function (instance){
instance.CodeMirror.setOption('keyMap','vim');
});
};
document.body.appendChild(vimBinding);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment