Visual Studio 2010 中的代码文件模板
Xcode 有一个功能,每种类型的文件都有一个模板,在创建该类型的文件时会填写该模板。默认情况下,这些文件位于 /Developer/Library/Xcode/Templates/File Templates
。
这些文件用于提供您想要的任何默认代码,例如通用文件头,甚至包括版权年份之类的内容。我已经非常习惯 Xcode 中的功能,但我发现自己在 Visual Studio 中缺少它。使用 VS,我必须手动复制粘贴标题并自己为每个文件修改它。有没有办法让 Visual Studio 自动用代码填充文件(例如 cpp 或 .h)?
编辑:我正在尝试用 C++ 来做到这一点。
Xcode has a feature where each type of file has a template that is filled out when that type of file is created. By default, those files are located at /Developer/Library/Xcode/Templates/File Templates
.
These files are used to give whatever default code you want, such as a common file header, even including things like the copyright year. I've gotten quite used to the functionality in Xcode, but I find myself missing it in Visual Studio. With VS I have to manually copy-paste the header and modify it myself for each file. Is there a way to get Visual Studio to automatically populate files (such as cpp's or .h's) with code?
EDIT: I'm trying to do this with C++.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您也可以在 Visual Studio 中使用带有宏等的模板。 MSDN 有一篇关于它的文章,并且有各种博客文章话题也。我知道它们适用于 C# 和 VB - 我希望 C++ 也能以同样的方式工作,但您当然需要检查一下。 (如果情况并非如此,请原谅。)
不幸的是,上次我看到它需要以一种似乎有点不必要的方式扩展然后压缩 zip 文件,但它应该是可行的。
Yes, you can use templates with macros etc in Visual Studio as well. MSDN has an article on it, and there are various blog posts on the topic too. I know they work for C# and VB - I expect C++ works in the same sort of way, but you'll need to check of course. (Apologies if this isn't the case.)
Unfortunately last time I looked it required expanding and then compressing zip files in a way that seemed a little unnecessary, but it should be doable.