Is there a way to indent the code in delphi? I have to work on a programm that has thousands of lines of code. In eclipse which i had worked before, i have used CTRL + SHIFT + F to format all code by formatting tabs/whitespaces and also divide code lines in a way that it is visible without horizontal scroll. Is there a way to do the same in delphi?
Asked
Active
Viewed 6,056 times
6
-
3You can use the tab key to indent, or `Ctrl + K + I` / `Ctrl + K + U` – Jerry Dodge Nov 12 '15 at 12:46
-
This may come in handy in the future: http://delphi.wikia.com/wiki/Default_IDE_Shortcut_Keys – Jan Doggen Nov 12 '15 at 13:14
-
1http://stackoverflow.com/questions/402737/delphi-code-formatter – LU RD Nov 12 '15 at 13:31
4 Answers
6
There is a way to format the code in the whole unit with indentation.
Menu -> Edit -> Format Source
You can also use Ctrl + K + I
and Ctrl + K + U
to indent current or selected lines.

kot-da-vinci
- 1,152
- 16
- 30
-
Is that option available in delphi 2007 also ? I am not able to see in my IDE – delsql Nov 12 '15 at 13:42
-
1
-
1@delsql you can try CnPack: http://www.cnpack.org It contains a tool for code formatting. – kot-da-vinci Nov 12 '15 at 14:13
-
[delphi shortcuts](http://delphi.wikia.com/wiki/Default_IDE_Shortcut_Keys). – Soon Santos Nov 06 '18 at 17:27
2
I assume you are looking for a way to format the code in the whole unit with indentation.
This is not included in the regular IDE. But there is a code formatter contained in an 'experimental' version of the GExperts:

mjn
- 36,362
- 28
- 176
- 378
0
- Activate CnPack -> Editor Enhancements -> Tab/ShiftTab to indent/unindent
- Press Alt then use the mouse to select a block text you want to indent. Note: with Alt pressed you can select multiple lines of code starting at a random column (opposite of what would happen if you don't press Alt, when your selection will be applied of full rows).
- Press Tab to move/indent the selected block of text.
My life would be sad without Alt+Block select then Tab.

Gabriel
- 20,797
- 27
- 159
- 293