visual-studio-code

Settings to copy paste with correct indentation in Visual Studio Code


When I copy and paste a piece of code using Visual Studio Code, after pressing enter to create a new line, the following happens:

enter image description here

It seems to keep the indentation created by the new line, adding the previous information from the copied snippet on top of it. I'd rather the code was auto-beautified on paste.

Can this behavior be changed through settings?

EDIT: I'm not referring to cross-platform copy-pasting, I'm referring to copying and pasting within the same file in Visual Studio Code.


Solution

  • This is already integrated in vscode with "editor.formatOnPaste": true property in settings.