keybinds.settings的语法是什么?

时间:2014-12-06 12:51:49

标签: keyboard-shortcuts cloud9-ide

keybinds.settings的语法是什么?我是vim用户,我最终会喜欢:

  • 将shift-j绑定为8行(nnoremap J 8j)
  • 与k(nnoremak J 8k)相同
  • 使用,作为"领导者",即我想约束",b" to" build",或许",g"运行" ghci文件名"在一个终端。

1 个答案:

答案 0 :(得分:4)

keybinding.settings文件目前仅适用于cloud9命令,要自定义vim命令,必须使用init脚本(参见Open Your Init Script item菜单中的Cloud9

您可以使用以下代码段

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");
});

请注意,对于,g,您需要创建ghci runner,有关详细信息,请参阅https://docs.c9.io/custom_runners.html