【问题标题】:change Atom keybinding behavior depending on character near cursor根据光标附近的字符更改 Atom 键绑定行为
【发布时间】:2021-10-05 04:49:37
【问题描述】:

在Atom text editor 中,如何根据光标左侧的字符使键绑定采取不同的操作?

特别是:

  • 如果光标左侧的字符是空白字符,那么我希望tab 键插入缩进。
  • 如果光标左侧的字符是不是空格,那么我希望tab 键打开自动完成窗格。

【问题讨论】:

    标签: keyboard-shortcuts atom-editor key-bindings


    【解决方案1】:

    你可以扩展这个扩展https://github.com/atom/autocomplete-plus.git。

    首先git clone repo, 如果你有它,从你的 atom 中删除扩展, 然后 cd 到你的克隆目录,然后使用apm link安装它

    在https://github.com/atom/autocomplete-plus/blob/master/keymaps/autocomplete-plus.cson 您可以添加标签:

    'atom-text-editor':
      'ctrl-space': 'autocomplete-plus:activate',
      'tab': 'autocomplete-plus:activate',
    

    和here line 501 ,在进入while循环之前, 你可以检查最后一个字符是否相等空格

    if(line[position.column - 1] == ' '){
        this.editor.indent()
    }
    

    并添加一级缩进。

    【讨论】:

    • 这听起来很有希望。有时间我看看能不能试试,谢谢!
    猜你喜欢
    • 2017-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-08
    • 2015-10-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多