Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Settings to copy paste with correct indentation in Visual Studio Code

People also ask

How do I turn on auto indent in Visual Studio?

Auto formatting settings in Visual Studio Show activity on this post. Select the text you want to automatically indent. Click menu Edit → Advanced → *Format Selection, or press Ctrl + K , Ctrl + F . Format Selection applies the smart indenting rules for the language in which you are programming to the selected text.

Does VSCode have auto indentation?

Automatically indent your code in VSCode Since version 1.14 released back in June 2017, automatic indentation feature has been added into Visual Studio Code codebase. Once enabled in the configuration, the auto-indentation feature will automatically indent your code whenever you type, move lines or paste lines.


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


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"
}

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