简体   繁体   中英

How to disable Auto ID in Visual Studio 2017

When copying and pasting HTML, VS helpfully renames all my variables to things like "Div1" & "Img1". Why!

I remember when using VS 2010 I think it was, there was a setting that allowed us to turn this "feature" off. Seems that feature no longer exists.

Are there any plugins or extensions or workarounds for this problem?

Seems that people have been complaining about this for years now:

How do I prevent Visual Studio from renaming my controls?

Disable "Auto ID elements" in Visual Studio 2013

https://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

You can use the following command (Language: C#) for my Visual Commander extension to paste text as is without renaming variables:

public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
    EnvDTE.TextSelection ts = DTE.ActiveDocument.Selection as EnvDTE.TextSelection;
    ts.Insert(System.Windows.Clipboard.GetText());
}

Here is the simplest workaround.
Simply make a comment first, then paste into the comment. When uncommenting, it will not apply Auto ID.

As a keyboard shortcut, it's CTRL+K,C,V,K,U on a new line.
Comment (KC), Paste (V), Uncomment (KU).

您可以在“选项”>“文本编辑器”>“HTML”中禁用此自动标记关闭,您可以在此处找到有关 html 编辑器的所有信息。在粘贴时搜索 AutoTag 或 Format Html!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM