10

Here are my original html codes:

<div class="container">
</div>
<div class="box box-1"></div>
<div class="box box-2"></div>
<div class="box box-3"></div>

and I just want to move the three div.box to div.container, but when I paste directly, it will be like this, just the fist line has correct indent:

<div class="container">
  <div class="box box-1"></div>
<div class="box box-2"></div>
<div class="box box-3"></div>
</div>

I followed the instruction to disable the aotoIndent in the settings, but didn't work, so how to handle it?

Revenant
  • 317
  • 3
  • 10
  • Have you checked this? https://stackoverflow.com/questions/41790069/settings-to-copy-paste-with-correct-indentation-in-visual-studio-code – informant09 Apr 16 '18 at 09:30
  • Possible duplicate of [Settings to copy paste with correct indentation in Visual Studio Code](https://stackoverflow.com/questions/41790069/settings-to-copy-paste-with-correct-indentation-in-visual-studio-code) – informant09 Apr 16 '18 at 09:31

3 Answers3

9

If you cannot set the editor.formatOnPaste to true. Then use the following key combination to manually format/ indent Alt+Shift+F

AbhishekGowda28
  • 994
  • 8
  • 19
  • Just to clarify. In settings you look under "DEFAULT USER SETTINGS" for `editor.formatOnPaste`. If it is set to `false`, copy the whole thing over to "USER SETTINGS" and put `true` instead. **But be aware it will affect all code you paste in to the editor.** – mikael1000 Aug 11 '18 at 00:10
2

I know you said this didnt worked for you, but it did work for me and it may help others i think it worth mentioning: This worked for me: Go to VS Code Settings -> from the User Settings tab -> Text Editor -> Formatting -> Untick the first option 'Format On Paste'

Ridha Rezzag
  • 3,672
  • 1
  • 34
  • 39
0

Since your settings aren't working as desired, one good way to handle this behavior is to highlight the text and press tab. This will increase indentation on all lines. You can repeat to get to your desired indentation level.