What is the syntax of keybinds.settings?

懵懂的女人 提交于 2019-12-10 17:14:40

问题


What is the syntax of the keybinds.settings? I am a vim user, and I would ultimately like to:

  • bind shift-j to go down 8 lines (nnoremap J 8j)
  • the same with k (nnoremak J 8k)
  • Use , as a "leader", i.e. I would like to bind ",b" to "build", and perhaps ",g" to run "ghci file-name" in a terminal.

回答1:


keybinding.settings file works only for cloud9 commands for now, for customizing vim commands you will have to use init script (see Open Your Init Script item in Cloud9 menu)

You can use following snippet

require(["plugins/c9.ide.ace.keymaps/vim/keymap"], function(vim) {
    var defaultKeymap = vim.aceKeyboardHandler.defaultKeymap;
    function ideCommand() { services.commands.exec(this.name); }
    function map(keys, action, context) {
        var mapping;
        if (!action) {
            return defaultKeymap.forEach(function(x) {
                if (x.keys == keys) {
                    x.defaultKeys = keys;
                    x.keys = "";
                }
            });
        } else if (/^c9:/.test(action)) {
            var commandName = action.substr(3);
            mapping = {
                keys: keys, type: "action", action: "aceCommand",
                actionArgs: { exec: ideCommand, name: commandName }
            };
        } else {
            mapping = { keys: keys, type: "keyToKey", toKeys: action };
        }

        if (context)
            mapping.context = context;
        mapping.user = true;
        defaultKeymap.unshift(mapping);
    }
    map("J", "8j", "normal");
    map("K", "8k", "normal");
    map(",", ""); // remove default mapping of ,
    map(",b", "c9:build", "normal");
    map(",g", "c9:run", "normal");
});

note that for ,g you need to create ghci runner, see https://docs.c9.io/custom_runners.html for details.



来源:https://stackoverflow.com/questions/27331865/what-is-the-syntax-of-keybinds-settings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!