44

In Tools > Options, I cannot find the setting to disable auto-renaming of elements which are pasted in HTML source view.

It used to be: Tools > Options > Text Editor > HTML > Miscellaneous > Auto ID elements on paste in Source view. But that option is gone in Visual Studio 2013.

How can I disable the auto-renaming?

Community
  • 1
  • 1
NightShovel
  • 3,032
  • 1
  • 31
  • 35
  • 5
    Looks like someone has created the same issue on the Microsoft Connect site a few days ago. It is under review. http://connect.microsoft.com/VisualStudio/feedback/details/806446/asp-net-web-forms-development-unable-to-disable-auto-id-generation-on-paste-using-new-version-of-visual-studio-2013 – Scott Wylie Nov 02 '13 at 02:04
  • 2
    To save other people time, unfortunately trying to add the registry key back of 'AutoIdSnippets' 0 doesn't seem to work. – mattmanser Nov 21 '13 at 17:16
  • 1
    Same issue here. Hope someone finds a resolution to this. Very annoying. – Bernesto Feb 27 '14 at 18:13

2 Answers2

31

For now the best solution seems to be a workaround that was posted by a user on the Microsoft Connect website which is to paste the code as a comment.

Fool the IDE that we're not pasting code (thus he won't alter it). How ? Paste a comment ! How to do that in real life ? Here is how I do it (feel free to suggest other ways!):

1) Place cursor where I want to paste code 2) ctrl-k, ctrl-c (i.e. comment region. Since no region was selected, an empty comment is inserted and our cursor Inside of it) 3) ctrl-v (paste content that is believed to be a comment by the IDE) 4) ctrl-k, ctrl-u (i.e. un-commenting the current comment we're in!

Lukkha Coder
  • 4,421
  • 29
  • 25
  • 17
    This workaround is hideous! How can this actually be a thing!? – Paul Jul 29 '15 at 14:59
  • @Paul: Could not agree with you more! – Lukkha Coder Jul 29 '15 at 19:02
  • To automate the workaround see http://stackoverflow.com/questions/31747485/is-there-any-plugin-to-disable-auto-id-on-paste-on-visual-studio-2013 – Sergey Vlasov Aug 03 '15 at 14:54
  • Such a great(!) solution by MS Connect. Pretty weird that this option does not exist in VS2017 whilst it is there in 2019 and versions earlier than 2013. – precise Feb 09 '21 at 07:22
  • 1
    @ErdemKAYA You mentioned that this is there in VS2019, but I don't see it. Can you please specify where you find it in VS2019? – Eric Barr Apr 11 '21 at 02:45
  • Fast forward to 2022, and this is truly the only way... -10 points to Microsoft for removing a great feature. – KZander Dec 01 '22 at 13:30
0

The auto ID assigning is made only if the ID is used by another control on the same page.

Copy the code and paste in external editor like Notepad++, then copy it again from NP++ and paste it in the code editor page, the ID should remain the same.

Ashraf Sada
  • 4,527
  • 2
  • 44
  • 48