Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one paste and indent in Visual Studio Code?

In Sublime text cmd+shift+v will paste and indent the code. Can this be done in visual studio code?

Workaround

I've made an extension that will let you paste and format with cmd/ctrl+shift+v. Search for pasteandformat

https://marketplace.visualstudio.com/items?itemName=spoeken.pasteandformat

like image 507
Spoeken Avatar asked Jan 06 '16 06:01

Spoeken


People also ask

How do I copy and paste an indent?

By default only the character formatting is copied; to include paragraph formatting, hold down Ctrl when you click. To copy only the paragraph formatting, hold down Ctrl+Shift when you click.

How do you paste a paragraph in Visual Studio Code?

One of the key feature in this release is in-built Terminal, which is docked in VS Code. In Windows machines Command Prompt, we can enable quick edit mode to paste the text from our clipboard by using right-click mouse. Windows shortcut for Copy & Paste are Ctrl+C & Ctrl+V which won't help us inside terminal.


1 Answers

Currently, Visual Studio Code doesn't provide this specific functionality. We could vote for this feature at Visual Studio's UserVoice website.

There's already a ticket open for this feature: Paste and auto align code. If you've got an account, you can vote for this feature so it gets more attention. If it has enough attention, Visual Studio Code's developers could take notice of this and maybe develop it.

Current workaround

After pasting the code, You could use CTRL+E, CTRL+D for windows or ALT+SHIFT+F for mac.

But note that this will reformat the whole document, indenting according to the available rules for the source type.

If you only want this to be applied to the pasted code, select the code after pasting and then use CTRL+E, CTRL+D for windows or ALT+SHIFT+F for mac. Now the indenting/formatting is only applied to the pasted lines.

like image 79
Dbuggy Avatar answered Oct 12 '22 23:10

Dbuggy