如何在VS Code中将用引号括起的高亮语义符号出现复制到剪贴板?

huangapple go评论57阅读模式
英文:

How can I copy a highlighted semantic symbol occurrence wrapped in quotes to the clipboard in VS Code?

问题

I understand your request. Here's the translated part:

在使用VS Code编辑XML文档时,例如,当我点击引号内部,比如

<section xml:id="agama-automated-installation-profile">

VS Code会为我高亮显示agama-automated-installation-profile字符串,但鼠标光标不会将其高亮显示为选择,因此无法使用CTRL+C复制它。

是否有一种简便的方式将这个片段复制到剪贴板上?

CTRL+C对于这个片段不起作用,因为实际选择是空的,因此整行都被复制了。

英文:

When editing an XML document in VS Code and after I click, for example, inside the quotes of

<section xml:id="agama-automated-installation-profile">

VSCode highlights the agama-automated-installation-profile string for me but it is not highlighted as a selection by mouse cursor therefore i cannot copy it by CTRL+C
如何在VS Code中将用引号括起的高亮语义符号出现复制到剪贴板?

Is there a shortcut to copy the snippet to the clipboard easily?

CTRL+C just does not work for this snippet because the real selection is empty and thus the whole line is copied.

答案1

得分: 0

你可以要么按下<kbd>Shift</kbd>+<kbd>Alt</kbd>+<kbd>Right</kbd>(命令Expand Selection)两次来选择所有内容,然后复制它,要么创建一个宏来在一步内执行它(使用内置命令runCommands):

{
  "key": "alt+g",  // 你想要的任何快捷键
  "command": "runCommands",
  "args": {
    "commands": [
      "editor.action.smartSelect.expand",
      "editor.action.smartSelect.expand",
      "editor.action.clipboardCopyAction",
      "cancelSelection"     
    ]
  }
}
英文:

You could either hit <kbd>Shift</kbd>+<kbd>Alt</kbd>+<kbd>Right</kbd> (the command Expand Selection) twice to select it all and then copy it, or create a macro to do it in one step (with the built-in command runCommands):

{
  &quot;key&quot;: &quot;alt+g&quot;,  // whatever keybinding you want
  &quot;command&quot;: &quot;runCommands&quot;,
  &quot;args&quot;: {
    &quot;commands&quot;: [
      &quot;editor.action.smartSelect.expand&quot;,
      &quot;editor.action.smartSelect.expand&quot;,
      &quot;editor.action.clipboardCopyAction&quot;,
      &quot;cancelSelection&quot;     
    ]
  }
}

huangapple
  • 本文由 发表于 2023年4月11日 16:58:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75984089.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定