有没有办法在 Visual Studio 项目模板中指定初始光标位置?

T G*_*ham 5 visual-studio-templates visual-studio-2012

例如,当您通过选择“添加”>“新建项目”>“Visual C# 项目”>“类”向项目添加类时,新类中闪烁的文本光标将位于第 1 行第 1 列。有没有办法修改模板以便闪烁的光标出现在不同的位置?

using System;

namespace SomeNamespace
{
    class SomeClass
    {
        | <--- I'd like the blinking cursor to initially appear here
    }
}
Run Code Online (Sandbox Code Playgroud)

mik*_*igs -1

您想使用$END$。您还可以通过用 $$ 包围其他关键字来创建字段。

using System;

namespace $Namespace$
{
    public class $ClassName$
    {
        $END$
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 仅限修磨机。请参阅:https://www.jetbrains.com/help/resharper/Templates__Template_Basics__Template_Variables.html。在 vanilla VS 中似乎没有任何方法可以做到这一点。 (3认同)