Sometimes it's useful to be able to swap two pieces of code. This extension simply copies anything selected when pasting and inserts it in the paste buffer. Note: Only works with single selections - multiple selections would get too complicated!
Overrides the default cut, copy, paste and undo key bindings. If you want to use in conjunction with another clipboard extension, set the appropriate commands as per the configuration below.
You can install the latest version of the extension via the Visual Studio Marketplace here.
Alternatively, open Visual Studio code, press Ctrl+P
or Cmd+P
and type:
> ext install swap-and-paste
The source code is available on GitHub here.
swap-and-paste.pasteCommand
If there is no selection when pasting, this command is executed instead. This allows you to use an alternative clipboard extension if required. Defaults to the standard editor.action.clipboardPasteAction
.
swap-and-paste.copyCommand
When copying the selected text, the extension will call this command after copying the selection to it's own clipboard. Defaults to the standard editor.action.clipboardCopyAction
.
swap-and-paste.cutCommand
When cutting the selected text, the extension will call this command after copying the selection to it's own clipboard. Defaults to the standard editor.action.clipboardCutAction
.
swap-and-paste.undoCommand
If you paste accidentally, undo will swap the selections back. The default is to call the standard undo command afterwards, but this can be overridden using this setting if required.
swap-and-paste.retainThroughDuplicateSelections
Normally, if xxx is copied and then pasted when yyy is selected, yyy is copied into the clipboard for the next paste. This is problematic if you want to do multiple replacements, so if yyy is selected subsequently again, xxx will be repasted. If you want to always swap yyy for xxx regardless of the previous paste contents, then set this false.
swap-and-paste.debug
Set to true to create a debug log in the Output panel.
Icon made by Freepik from www.flaticon.com