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:
editor
is not defined) 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.
In the latest version of ace (v1.1.1), vim and emacs bindings come built in. The following works:
editor.setKeyboardHandler("ace/keyboard/vim");
I posted on the ace Google Group (+rep to Harutyun) and received a reply with the following code:
ace.require("ace/lib/net").loadScript("https://rawgithub.com/ajaxorg/ace-builds/master/src-min-noconflict/keybinding-vim.js",
function() {
e = document.querySelector(".ace_editor.ace-github").env.editor;
e.setKeyboardHandler(ace.require("ace/keyboard/vim").handler);
})
Which works like a charm (Do note that the version of ace that github uses may change, which may break this).
It's a pain to enter this into the console each time, so I plan on adding it to a greasemonkey script (a chrome plugin might be nice! -- well see).
Update
I've written a small Chrome Extension that enables Vim bindings on most sites Ace.js and CodeMirror. Issues and contributions welcome at the github repo
I wasn't able to get the other two solutions to work. (Nick's Chrome extension still works perfectly for me, though.)
Another solution is to change to vim
mode in the settings menu.
To access the settings menu, make sure the ACE editor has focus, and push ctrl
+,
(Control and Comma).
This will open the menu on the right hand side of the screen. Find the "Keyboard Handler" dropdown and select vim
. Push escape
or click somewhere off of the settings menu to close it.
vim
mode should now be activated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With