Own double-tab templates in Visual Studio 2012

折月煮酒 提交于 2019-12-20 04:25:14

问题


So there's a trick in Visual Studio, that when you type, for example 'for', and double-press the Tab key, Visual Studio will create

for (int i = 0; i < length; i++)
        {

        }

Is there any way to create my own templates? As I don't use LINQ I'd like to, when 'db.A_' is typed, to make

db.A_TableName.Where(k => k.Field == Value).Select(k =>
    new
    {
        Name = k.Field
    });

回答1:


You are probably referring to code snippets. The docs explain how to create new snippets and how to add them. It might be easiest to create new ones based on existing snippets that can be found in the folder C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC#\Snippets\1033\Visual C# (depending on your VS version and OS).




回答2:


In visual studio has more default snippets which is in

C:\Program Files (x86)\Microsoft Visual Studio (#Version)\VC#\Snippets\1033

file path as a xml format.

Also we can add some more custom snippets to our local machine.This is machine specific.

click here for dotnetperls documentation about snippets



来源:https://stackoverflow.com/questions/15186658/own-double-tab-templates-in-visual-studio-2012

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!