【问题标题】:Replace "< -" keystroke combination for a custom shortcut in VS Code替换 VS Code 中自定义快捷键的“< -”按键组合
【发布时间】:2020-10-01 03:11:12
【问题描述】:

我想知道如何设置快捷键,例如 CRTL+F 用于击键&lt;- 以获得更好的 R 语言编程体验。甚至当我输入- 时,它也会在我的编码脚本上打印出完整的&lt;-

我可以在 RStudio 中设置它,但在 VS 代码中找不到这样做的方法。 VS Code 中的快捷方式选项总是与 IDE 命令相关联,对我一点帮助都没有。

有什么想法吗?

【问题讨论】:

    标签: visual-studio-code shortcut


    【解决方案1】:

    或者将这个方便的键盘快捷键示例与文档页面中的参数一起使用

      {
        "key": "ctrl+f",
        "command": "type",
        "args": { "text": "<-" },
        "when": "editorTextFocus && editorLangId == r"
      },
    
    

    【讨论】:

      【解决方案2】:

      你也可以定义一个用户sn-p。例如,将其放入您的 snippets\r.json 文件中:

      "assign": {
          "prefix": "=",
          "body": " <- ",
          "description": "left arrow assignment"
      }
      

      现在,输入 =Tab 将插入 &lt;-

      【讨论】:

        【解决方案3】:

        只需将以下代码添加到keybinding.json 文件即可:

        // Place your key bindings in this file to override the defaults
        [
          {
            "key": "oem_minus oem_minus",
            "command": "type",
            "args": {
              "text": "<-"
            },
            "when": "editorTextFocus"
          }
        ]
        

        完美运行。当我输入-- 时,它会打印出&lt;-

        【讨论】:

        • 还在when 子句中添加一个languageId 比较。当你编写一个 C/C++/Java/JavaScript/... 程序时,你会感到惊讶
        • 我该怎么做?我只希望在 R 中进行这种转换。你能帮我吗?
        • 是的,你肯定想要那个 when 子句,当你写 C++ 代码时你不想要这个替换
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-08-28
        • 1970-01-01
        • 2012-08-28
        • 2018-01-03
        • 2012-07-16
        • 1970-01-01
        • 2011-05-11
        相关资源
        最近更新 更多