Reputation: 21134
There is a 'Variable completion' feature in Delphi XE? I ask because I know there are lots of hidden or semi-hidden features (like the possibility to change the execution point when you are in debugging mode) in Delphi.
Example: http://wiki.freepascal.org/Lazarus_For_Delphi_Users#Example_for_Local_Variable_Completion
That I want to achieve:
When I need a new variable in the middle of a procedure, I don't want to go back at the top of the procedure to declare it and then go back in the middle of the procedure. So, it is not that I am lazy in copy/pasting the variable name but that I am disturbed in the middle of the 'creative process'.
I think this tiny feature will be a gigantic improvement to Delphi and to our efficiency.
Upvotes: 0
Views: 238
Reputation: 125669
There's a template available that will add the variable declaration somewhat automatically, but it does have some issues. Type var
in your code and press Ctrl+J:
begin
var(Ctrl+J)
end;
This produces the following in the Code Editor:
Enter a name for the variable, Tab, enter a type for the variable, Tab adds the variable declaration at the top of the current procedure or method. For instance, adding an integer variable named Idx
produces
with the text cursor immediately below the g
in begin
(with my IDE settings of 2-space indentation).
The drawback is that it doesn't automatically type the variable name on the line where the text cursor is located, meaning you have to type the name again (or at least start typing and use Code Completion to finish) in order to use it.
Upvotes: 1
Reputation: 47704
There is something similar in the Refactoring menu. You have to select the variable to declare first and then hit Ctrl-Shift-V. In the following dialog you can accept the type suggestion or change it to your needs.
More information can be found here: http://docwiki.embarcadero.com/RADStudio/XE/en/Declare_Variable_and_Declare_Field_Overview_(Delphi)
Upvotes: 1