Reputation: 761
I don't know if this exists but I would like to have the equivalent of Shift+ Alt + Up|Down which duplicates the line up or down, but horizontally with the text selected.
For example, let's consider this program:
print("Hello world")
If the selected text is Hello world
and I do the shortcut it will give something like:
print("Hello worldHello world")
Basically, it would ideally be Shift+ Alt + Right|Left but this shortcut doesn't do that.
Upvotes: 2
Views: 1052
Reputation: 180785
Here is how to do the paste to the right repeatedly. You will need this extension which I wrote Find and Transform:
Make this keybinding:
{
"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"
}
}
First, select what you want to repeat to the right. Second, trigger either keybinding.
It works by doing a find
for the clipboard content (and automatically selecting it) each time after the paste.
The only caveat is it won't work if you have the exact same text as the selected text earlier on the same line.
Upvotes: 1
Reputation: 28633
use extension multi-command
Define the following key bindings
{
"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"
]
}
}
Upvotes: 0