Vim editor for Github

Today there was a topic on HN about Vim.js, a JavaScript port of Vim. Some people were asking about a way to integrate the Vim editor with Github.

Github currently uses Ace editor, and I remembered that it had a Vim mode from the time when I was implementing Ace with Datazenit. You can press CTRL+, or CMD+, (depends on your OS) to access Ace’s settings menu and enable Vim mode there (screenshot). The menu itself works ok, but sadly the Vim mode doesn’t, because some required JavaScript files are not available from Github. However it can be easily fixed – we just need to include the correct JS module and we get a working Vim editor in Github. Paste the following code (found on SO) in your developer tools console:

ace.require("ace/lib/net").loadScript("https://raw.github.com/ajaxorg/ace-builds/master/src-min-noconflict/keybinding-vim.js", function() { 
  e = $(".file-contents").codeEditor().editor;
  e.setKeyboardHandler(ace.require("ace/keyboard/vim").handler); 
})

Update! Github changed some HTML code structure, so I have updated the snippet above.