设置单位默认值?
这不是一个编程问题,但是
......Delphi IDE 有没有办法定义将应用于新创建的单元的信息?
例如,假设我希望每个新单元在顶部添加一些注释信息,如下所示:
I希望将此类信息添加到单元中,以便其他可能需要访问它的人可以获得一些简短的信息。显然我并不期望 IDE 填写概述信息。
我注意到一些开源组件在单元顶部包含许可证信息,我假设它们只是复制并粘贴到那里,但如果有一种方法可以自动化此类 IDE 行为,那不是很方便吗?
此外,我还在我的库路径中添加了一些外部单元,在需要时我将其添加到表单/单元的使用子句中。我总是发现自己使用一种特定的单位,自动将 X 单位包含到新单位的使用条款中也会很方便。
做这样的事情有什么技巧吗,还是复制和粘贴就足够了?
谢谢。
Not a programming question as such, but..
..Is there a way from the Delphi IDE to define information that will be applied to newly created Units?
For example, suppose I wanted each new Unit to add some commented information to the top, like so:
I like to add such information to Units so that anyone else who may need access to it has some brief information. Obviously I am not expecting the IDE to fill in the Overview information.
I noticed some OpenSource Components include the License Information at the top of Units, I assume they were just Copy and Pasted in there, but wouldnt it be handy if there was a way to Automate such IDE behaviour?
Additionally, I have a few external Units added to my Library Path, which I add to the Uses Clause of a Form/Unit when needed. There is one paticular Unit I always find myself using, It would also be handy to Automatically include X Unit to the Uses Clause of New Units.
Is there a trick to doing something like this, or should Copy and Paste be enough?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您也可以考虑使用
Delphi 实时模板
。You can consider using a
Delphi live template
too.您可以获得的最接近的是使用 GExperts 或 CNPack。这些都是很棒的 IDE 增强功能,可用于使用简单的热键粘贴可配置的代码片段。在GExperts中这被称为Code Librarian,CNPack也有类似的功能。它们包含许多其他有价值的工具,因此值得检查一下。
The closest you can get is to use GExperts or CNPack. These are great IDE enhancements and they can be used to paste configurable pieces of code using a simple hotkey. In GExperts this is called Code Librarian, CNPack has a similar feature. They contain a lot of other valuable tools so it might be worth to check these out.
就像 Marjan 已经提到的使用专家来创建新的自定义单元一样,您还可以让 IDE 专家重写 Delphi 的默认单元代码以获得最大的可定制性。但由于这个答案可能意味着最需要的工作,因此我不会详细介绍或示例代码。这只是一种可能性。
Like Marjan already mentioned using an expert for a new custom unit, you can also make an IDE expert rewriting Delphi's default unit code for maximum customizability. But since this answer likely implies the most required work of all, I shall not go in detail or sample code. It's just a possibility.
您必须坚持复制/粘贴。如果有一种巧妙的方法来做到这一点,那么地球上的每一个 Delphi 程序员都会用它来把它变成
这样
You'll have to stick to copy/paste. If there was a slick way to do this then every single Delphi programmer on the planet would have used it to turn this
into this