Settings to copy paste with correct indentation in Visual Studio Code

Ctrl + V followed by Ctrl + Z seems to work out of the box.


This plugin may help you:

paste-and-indent extension

You just have to change the shortcut and it works. Remember that you probably want to use 'cmd' instead of 'ctrl' if you're on a mac. Like this:

{
    "key": "ctrl+v",
    "command": "pasteAndIndent.action",
    "when": "editorTextFocus && !editorReadonly"
},
{
    "key": "ctrl+v",
    "command": "editor.action.clipboardPasteAction",
    "when": "!editorTextFocus"
},
{
    "key": "ctrl+shift+v",
    "command": "editor.action.clipboardPasteAction",
    "when": "editorTextFocus && !editorReadonly"
}

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