IDE option which defines what directive is put in newly created unit lazarus / 9-Editor ---------------------------------------------------------------------- Zoran · 2016-01-08 07:23 When a new unit is created, Lazarus automatically puts directive "{$mode objfpc}{$H+}". Is there an option which changes this? I can't find it, so I'm afraid it cannot be changed. I'd like to add "{$ModeSwitch DuplicateLocals}" to this. It is not big deal for me, I can add it manually to new units, but I would like to know if it exists. ---------------------------------------------------------------------- x2nie · 2016-01-08 08:14 you asked 2 questions. 1)) To change the $mode: a) Lazarus menu: Project > Project Options. Or from Project Inspector Dialog: > Options. b) in Project Options dialog: Compiler OPtions > Parsing c) in Syntax Mode combobox, change as what you wanted.  see attachment Note: by default,it run per-project (or per package) basis. If you want it change globally, in Project Options Dialog checkmark the "Set Compiler Options as Default" PS: I never know about it in before. Just after you asked, I track the source code, and there is a "frame" (frame of Options dialogs). 2)) For adding more compiler options to the unit file, I couldn't found any way for such adding them via dialog. But you have to try one of several way out: (A) edit the "unit generator" directly (B) inherit unit generator and register them to the IDE. A): edit file Lazarus\components\ideintf\projectintf.pas Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i class function TFileDescPascalUnit.CompilerOptionsToUnitDirectives(  CompOpts: TLazCompilerOptions): string;var  SyntaxMode: String;begin  Result:='{$mode objfpc}{$H+}';  if CompOpts=nil then exit;  SyntaxMode:=CompOpts.SyntaxMode;  if SyntaxMode<>'' then begin    Result:='{$mode '+lowercase(SyntaxMode)+'}';    if CompOpts.UseAnsiStrings    and (SysUtils.CompareText(SyntaxMode,'Delphi')<>0) then      Result:=Result+'{$H+}';  end;    Result := Result + LineEnding + '{$ModeSwitch DuplicateLocals}'; // <----------do whatever like thisend; B): learn how TProjectDescriptor works. I learn it from fpgui's ProjectDescriptor. ---------------------------------------------------------------------- Zoran · 2016-01-08 09:56 Thank you, x2nie, for so complete answer. Quote from: x2nie on January 08, 2016, 09:14:10 amyou asked 2 questions. I didn't mean to ask two questions. Sorry, I wasn't specific enough. My original question was simply if I could put customized directives instead of the default. I knew about the "Syntax Mode" settings under project's compiler options, but this actually affects the compiler syntax mode (compiler is called with this option, -Msome_mode added. That is what I expected, the option to put customized directives does not exist. However, when I have more time, I'll try to offer a patch which adds this. This thorough answer you gave here will be very helpful for me then.