在VisualStudioCode中横向复制选定文本的快捷方式



我不知道这是否存在,但我希望有等效的Shift+Alt+向上|

Down例如,让我们考虑一下这个程序:

print("Hello world")

如果选择的文本是Hello world,并且我执行快捷方式,它会给出类似于:

print("Hello worldHello world")

基本上,理想情况下是Shift+Alt+Right|Left

以下是如何重复向右粘贴。你将需要这个扩展,我写了查找和转换:

制作此密钥绑定:

{
"key": "shift+alt+right",
"command": "findInCurrentFile",
"args": {
"preCommands": [
"editor.action.clipboardCopyAction",
"cursorRight",
"editor.action.clipboardPasteAction",
"cursorHome"  // return cursor to beginning of line
],
"find": "${CLIPBOARD}",
"restrictFind": "once"  // refind the clipboard text, use only the first find match
}
},
{
"key": "shift+alt+left",
"command": "findInCurrentFile",
"args": {
"preCommands": [
"editor.action.clipboardCopyAction",
"cursorLeft",
"editor.action.clipboardPasteAction",
"cursorHome"
],
"find": "${CLIPBOARD}",
"restrictFind": "once"
}
}

首先,选择要向右重复的内容。第二,触发任意一个键绑定。

它的工作原理是每次粘贴后对剪贴板内容执行find(并自动选择(。

唯一需要注意的是,如果您在同一行上有与前面所选文本完全相同的文本,那么它将不起作用。

  • 实际上,不需要两个命令,因为它们会产生相同的无法区分的结果

使用扩展多命令

定义以下密钥绑定

{
"key": "shift+alt+left",
"command": "extension.multiCommand.execute",
"args": { 
"sequence": [
"editor.action.clipboardCopyAction",
"cursorLeft",
"editor.action.clipboardPasteAction"
]
}
},
{
"key": "shift+alt+right",
"command": "extension.multiCommand.execute",
"args": { 
"sequence": [
"editor.action.clipboardCopyAction",
"cursorRight",
"editor.action.clipboardPasteAction"
]
}
}

最新更新