如何删除vscode片段中该行的内容

问题描述 投票:0回答:1

我制作了一个包含一些片段的 vscode 扩展。例如这个:

    "header4": {
        "prefix": "header 4",
        "body": [
            "[header 4](Text='')"
        ],
        "description": "Write a description for this snippet"
     }

当我写他...时,它会显示该片段,我可以单击它。一切都很好,它写的是 [header4]Text='')。 当我尝试写 [he... 因为我找到了代码片段,但它写的是 [[header4]Text='')] 时,我的问题就出现了。我不想要那些括号。我想删除这些括号。有人知道该怎么做吗?

我尝试添加变量,但没有变量可以帮助我。我尝试输入命令bracketeer.removeBrackets,但也不起作用。 有什么帮助吗? 谢谢你

vscode-extensions
1个回答
0
投票

尚不完全清楚您需要什么,

但为了回答如何使用片段删除一行内容的一般问题,我已经能够使用

keybindings.json
根据我的需要拼凑出一个工作解决方案。它涉及利用运行多个命令的能力。请参阅:https://code.visualstudio.com/docs/getstarted/keybindings


// Place your key bindings in this file to override the defaults
[
  {
    "key": "shift+ctrl+;",
    "command": "runCommands",
    "args": {
      "commands": [
        {
          "command": "editor.action.insertSnippet",
          "args": {
            "snippet": "$1\nconsole.log('Lalonde ${TM_CURRENT_LINE/^.*?([^\\s]+)\\s*$/$1/} [${TM_LINE_NUMBER}]', ${TM_CURRENT_LINE/^.*?([^\\s]+)\\s*$/$1/})\n"
          }
        },
        {
          "command": "cursorHomeSelect"
        },
        { "command": "deleteLeft" },
        { "command": "prettier.forceFormatDocument" }
      ]
    },
    "when": "editorTextFocus && (editorLangId == 'typescript' || editorLangId == 'javascript' || editorLangId == 'typescriptreact' || editorLangId == 'javascriptreact')"
  },
]

© www.soinside.com 2019 - 2024. All rights reserved.