【问题标题】:What is the syntax of keybinds.settings?keybinds.settings 的语法是什么?
【发布时间】:2014-12-06 12:51:49
【问题描述】:

keybinds.settings 的语法是什么?我是 vim 用户,我最终希望:

  • 绑定 shift-j 向下 8 行 (nnoremap J 8j)
  • 与 k (nnoremak J 8k) 相同
  • 使用 , 作为“leader”,即我想将“,b”绑定到“build”,也许还想将“,g”绑定到终端中运行“ghci file-name”。

【问题讨论】:

    标签: keyboard-shortcuts cloud9-ide


    【解决方案1】:

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

    你可以使用下面的sn-p

    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-13
      • 2011-11-14
      • 1970-01-01
      • 2020-06-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-17
      • 2020-04-18
      相关资源
      最近更新 更多