Forum > Editor
Identifier capitalization?
Peter H:
Hello,
I want for all Identifiers in a progamm to make the capitalization equal to the declaration.
Example:
var
VeryImportantNumber:integer;
"if veryimportantnumber = 0 then"
should become
"if VeryImportantNumber = 0 then"
and this for all identifiers in the program.
Is this possible?
Handoko:
Use Find & Replace feature:
Source Code Editor > Ctrl + F > fill the Text to find field > Enable the Replace with checkbox and provide the identifier with the correct capitalization > Disable Case sensitive checkbox > Set the Origin option to From beginning > Set the Search scope option to Global > Set the Direction to Forward search > Click the Replace All button
If you want to do it on multiple files:
Lazarus main menu > Search > Find in files
I'm not sure, I don't use it but I think you can also try JEDI Code Format:
Lazarus main menu > Source > JEDI Code Format
Peter H:
Yes thank you, but this will only work for a single identifier.
I think this can also (and better) be done with "Refactor" but this also works on a single identifier.
I tried Jedi Code format, this doesnt do it, it only unifies the capitalization for keywords.
I watched on Youtube tutorial videos for delphi where identifiers are automatically correctly capitalized during or after typing and I asked myself if there is a similar feature or tool for freepascal/Lazarus.
Thereoretically the compiler could do this, because the compiler knows and understands all declarations.
PascalDragon:
--- Quote from: Peter H on November 30, 2020, 12:57:24 pm ---I watched on Youtube tutorial videos for delphi where identifiers are automatically correctly capitalized during or after typing and I asked myself if there is a similar feature or tool for freepascal.
--- End quote ---
Lazarus does that as well when you use its code completion (Default: Ctrl + Space) functionality (if there is only one valid identifier it will complete that without showing the code completion window).
--- Quote from: Peter H on November 30, 2020, 12:57:24 pm ---Thereoretically the compiler could do this, because the compiler knows all declarations.
--- End quote ---
No, the compiler does not modify source files.
Handoko:
--- Quote from: Peter H on November 30, 2020, 12:57:24 pm ---I tried Jedi Code format, this doesnt do it, it only unifies the capitalization for keywords.
--- End quote ---
You can configure it:
Lazarus main menu > Source > JEDI Code Format > Format Settings > left panel: Clarify > Capitalization > Identifiers
--- Quote from: Peter H on November 30, 2020, 12:57:24 pm ---I watched on Youtube tutorial videos for delphi where identifiers are automatically correctly capitalized during or after typing and I asked myself if there is a similar feature or tool for freepascal.
--- End quote ---
Just as PascalDragon said. I always use Ctrl+Space when typing identifier so my codes are always capitalized uniformly.
Navigation
[0] Message Index
[#] Next page