Sign in Join
Wiki copytemporary

IDE directives: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-## Contents
2-
3- * 1 Overview
4- * 2 Hide one hint, note or warning
5- * 3 File encoding
6- * 4 Run/Build file
7- * 5 Other IDE Directives
8- * 6 Reading / finding IDE directives
9-
101# Overview
112
12-IDE directives are similar to compiler directives: a special kind of comment placed in your source code. They are enclosed by curly brackets with an opening percentage sign. For example:
13-```
3+IDE directives are similar to compiler directives: a special kind of comment placed in your source code. They are enclosed by curly brackets with an opening percentage sign. For example:
4+
5+``` pascal
146{%H-}
157```
168
17-The compiler sees them simply as comments which it ignores. The IDE uses these directives to store source-specific information which is independent of project and session.
9+The compiler sees them simply as comments which it ignores. The IDE uses these directives to store source-specific information which is independent of project and session.
1810
1911# Hide one hint, note or warning
2012
21-To hide a single hint, note or warning you use the following IDE directive:
22-```
13+To hide a single hint, note or warning you use the following IDE directive:
14+
15+``` pascal
2316procedure DoSomething({%H-}NotUsed: char);
24- begin
25-
26- end;
27-```
17+begin
2818
29-This will suppress the line in the Lazarus Messges window that otherwise would report
30-```
31-Hint: Parameter "NotUsed" not used
19+end;
3220```
3321
34-The compiler still issues the Hint, but the {%H-} IDE directive causes the IDE to filter the Hint out of the Messages view.
22+This will suppress the line in the Lazarus Messges window that otherwise would report
3523
36-Note: You can right click on a hint in the message window and choose the context menu option "Hide message via directive" to insert the directive automatically.
24+`Hint: Parameter "NotUsed" not used`
3725
38-This feature was introduced in Lazarus 0.9.29.
26+The compiler still issues the Hint, but the {%H-} IDE directive causes the IDE to filter the Hint out of the Messages view.
3927
28+Note: You can right click on a hint in the message window and choose the context menu option "Hide message via directive" to insert the directive automatically.
29+
30+This feature was introduced in Lazarus 0.9.29.
31+
4032# File encoding
4133
42-You can specify what encoding the IDE should use for a source file by adding a BOM or an encoding directive at the very start of a source file:
43-```
34+You can specify what encoding the IDE should use for a source file by adding a BOM or an encoding directive at the very start of a source file:
35+
36+``` pascal
4437{%encoding CP1250}
4538```
4639
47-See the unit lcl/lconvencoding.pas for all possible values.
40+See the unit lcl/lconvencoding.pas for all possible values.
4841
4942# Run/Build file
5043
51-The IDE can run and build single files instead of projects. The parameters for building/running a file are stored as IDE directives within the file itself.
44+The IDE can run and build single files instead of projects. The parameters for building/running a file are stored as IDE directives within the file itself.
5245
53- * {%BuildCommand <command line used for building, default is $(CompPath) $(EdFile)>}
54- * {%BuildWorkingDir <working directory, default is the file path>}
55- * {%BuildScan <parsers>} List of parsers used for build output
56- * {%RunCommand <command line used to run, default is $NameOnly($(EdFile))>}
57- * {%RunWorkingDir <working directory, default is the file path>}
58- * {%RunFlags <flags, default Build+>} where flags is a space separated list of options. E.g. {%RunFlags Messages+ Build+}
59- * Build+ build before run, default: on
60- * Messages+ show run output in the Messages window, default: off
46+- {%BuildCommand \<command line used for building, default is \$(CompPath) \$(EdFile)\>}
47+- {%BuildWorkingDir \<working directory, default is the file path\>}
48+- {%BuildScan \<parsers\>} List of parsers used for build output
49+- {%RunCommand \<command line used to run, default is \$NameOnly(\$(EdFile))\>}
50+- {%RunWorkingDir \<working directory, default is the file path\>}
51+- {%RunFlags \<flags, default Build+\>} where flags is a space separated list of options. E.g. {%RunFlags Messages+ Build+}
52+ - Build+ build before run, default: on
53+ - Messages+ show run output in the Messages window, default: off
6154
62-See [[IDE Window: Configure Build file|Configure Build File]].
55+See [[IDE Window: Configure Build file|Configure Build File]].
6356
6457# Other IDE Directives
6558
66- * {%Region} Allows you to define your own [[IDE Window: Editor Options Code Folding|Code Folding]] blocks, by putting this special comment into the code. You have to specify the end of the folded region with {%Endregion}
67- * {%MainUnit path/to/unit.pas} Used as first line in an include file to give codetools a hint where the unit file is. Any **/** and **\** are converted to the current path delimiter.
59+- {%Region} Allows you to define your own [[IDE Window: Editor Options Code Folding|Code Folding]] blocks, by putting this special comment into the code. You have to specify the end of the folded region with {%Endregion}
60+- {%MainUnit path/to/unit.pas} Used as first line in an include file to give codetools a hint where the unit file is. Any **/** and **\** are converted to the current path delimiter.
6861
6962# Reading / finding IDE directives
7063
71-The codetools unit basiccodetools contains several functions for reading IDE directives:
64+The codetools unit basiccodetools contains several functions for reading IDE directives:
7265
73- * FindNextIDEDirective
74- * CodeToolBoss.GetIDEDirectives
66+- FindNextIDEDirective
67+- CodeToolBoss.GetIDEDirectives
7568
7669---
77-*From the Free Pascal wiki, page "IDE directives", as the Internet Archive kept it on 2025-03-23. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
70+*From the Free Pascal wiki, page "IDE directives", as it stood on 2020-02-17 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history