Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Swap and PasteNew to Visual Studio Code? Get it now.
Swap and Paste

Swap and Paste

Gruntfuggly

|
117 installs
| (0) | Free
Copy the selected text before pasting
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Swap and Paste

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.

Installing

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

Source Code

The source code is available on GitHub here.

Configuration

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.

Credits

Icon made by Freepik from www.flaticon.com

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft