Enable Vim mode in gist Ace Editor

Nick Tomlin picture Nick Tomlin · Mar 18, 2013 · Viewed 8.5k times · Source

I'm trying to enable the Ace's keyBoard handler for my beloved Vim on github gists. This seems like it would be an easy thing to do, but I am struggling to:

  1. Find the object that the gist ace editor is attached to (the ace default editor is not defined)
  2. Set it to use VIM, via github's hosted Vim binding: https://gist.github.com/assets/ace/keybinding/vim-b9f3b98dd13151f9b4c7279d8259b69e.js

I found the following snippet on the Ace Google Group:

env.editor.setKeyboardHandler(require("ace/keyboard/keybinding/vim").Vim)

But that doesn't work (even if I substitute the github url) so i'm assuming that that applies to the Cloud9 IDE, and not selfhosted/custom Ace.

Answer

brianmearns picture brianmearns · Nov 27, 2013

In the latest version of ace (v1.1.1), vim and emacs bindings come built in. The following works:

editor.setKeyboardHandler("ace/keyboard/vim");