如何在Delphi IDE中更快地创建自动属性? [英] How to create an auto-property faster in Delphi IDE?
问题描述
我需要创建和管理许多简单的已发布属性。我称之为自动属性,如果它们是这样的:
private
FTitle:string;
发布
属性标题:string read FTitle write FTitle;
通常我会创建他们的方式:
-
添加属性名称和类型:
属性标题:string
/ p> -
选择并复制属性名称
标题
到剪贴板。 -
使用
追加行读取F
Ctrl + V写入F
Ctrl + V;
- 按 Ctrl + Shift + C ,这将生成私有字段
有没有办法排除步骤2和3更快地添加属性?也许可以为此创建一些宏?
自从Delphi 2006以来,您可以使用LiveTemplates。
在Delphi XE中,例如:
- type
propf
并点击 Ctrl + J 击键 - 写入属性名称,并点击 TAB 键
- 写入属性类型名称,点击 TAB 或< kbd> ENTER 键,你完成了
您可以在这里找到更多关于如何编写自己的Live Templates的信息:
I need to create and manage many simple published properties. I call them auto-properties if they look like that:
private
FTitle: string;
published
property Title: string read FTitle write FTitle;
Usually I create them next way:
Adding property name and type:
property Title: string
Selecting and copying property name
Title
to clipboard.Appending the line with
read F
Ctrl+Vwrite F
Ctrl+V;
- Pressing Ctrl+Shift+C and this will generate the private field
Is there any way to exclude steps 2 and 3 to add properties faster? Maybe it is possible to create some macro for this?
Since Delphi 2006 you can use LiveTemplates.
In Delphi XE for example:
- type
propf
and hit Ctrl + J keystroke - write the property name and hit TAB key
- write the property type name, hit TAB or ENTER key and you are done
You can find more information on how to write your own Live Templates here:
Delphi Live Templates - http://delphi.wikia.com
Creating Live Templates - http://docwiki.embarcadero.com
这篇关于如何在Delphi IDE中更快地创建自动属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!