10

How do you customize the Copy/Paste behavior in Visual Studio 2008?

For example I create a new <div id="MyDiv"></div> and then copy and paste it in the same file.

VisualStudio pastes <div id="Div1"></div> instead of the original text I copied.

It is even more frustrating when I'm trying to copy a group of related div's that I would like to copy/paste several times and only change one part of the id.

Is there a setting I can tweak to change the copy/paste behavior?

Brian Boatright
  • 36,294
  • 34
  • 81
  • 102

2 Answers2

22

Go into Tools > Options > Text Editor > HTML > Miscellaneous and uncheck "Auto ID elements on paste in Source view"

DamienG
  • 6,575
  • 27
  • 43
  • 1
    I just found that. The only drawback is it doesn't handle ID at all now in source view. So if you drag & drop a GridView or some other element you have to make sure to add an ID. – Brian Boatright Sep 15 '08 at 21:52
  • 1
    While I can see how that can be bad when trying to rapidly prototype, I almost feel like it should be the standard setting for production code development. Too may a times I've seen CheckBox1, CheckBox2, etc. in production code that needs some maintenance. – Serhiy Mar 20 '12 at 14:10
1

In Visual Studio 2019 the new location is
Tools > Text Editor > ASP.NET Web Forms
and Check Format HTML on paste.
So now it is possible to efficiently duplicate sequential ID codes.

DuDa
  • 3,718
  • 4
  • 16
  • 36
Geospatial
  • 31
  • 8