Settings to copy paste with correct indentation in Visual Studio Code

前端 未结 4 1355
逝去的感伤
逝去的感伤 2021-01-30 01:02

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

It seems to k

相关标签:
4条回答
  • 2021-01-30 01:44

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

    0 讨论(0)
  • 2021-01-30 01:55

    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"
    }
    
    0 讨论(0)
  • 2021-01-30 01:59

    A simple fix is to try Ctrl + Shift + V after copying the code. It will paste all codes correctly with indentations in it.

    0 讨论(0)
  • 2021-01-30 02:04

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

    0 讨论(0)
提交回复
热议问题