Tidy

Previous Top Next

Tidy functions

Tidy can do all or any of the following

Example 1 - Standard indentation and capitalisation:

graphicgraphic

Example 2 - Simple syntax Check:

graphicgraphic

If it finds a syntax problem, Tidy will insert warning comments as shown below and indicate the number of errors found in the lower pane of the editor. In this case the End If is incorrectly spelt and so does not close the If before the Func starts. When the error is fixed, just run Tidy again and all the inserted lines will be removed automatically.  If multiple errors are shown, always start by fixing the first one and rerunning Tidy as the subsequent errors may flow from an incorrect structure earlier in the script as in the example shown.

Running Tidy

Tidy can be run in several ways:

From within SciTE by pressing Ctrl-T

Run Tidy.exe directly and a dialog will ask for the input file

Right-click on an .au3 file and select Tidy (if the full SciTE4AutoIt3 package has been installed)

Setting Tidy options

Tidy default options are set in Tidy.ini which is stored in folder %LOCALAPPDATA%\AutoIt v3\SciTE\Tidy when using the Installer version and ...\AutoIt3\SciTE\Tidy  for the portable version
Use these directives to disable tidy for a block of code:
#Tidy_Off 
#Tidy_On
#Tidy_Parameters
These settings can be overridden by specifying the below parameters on the Tidy commandline or  #Tidy_Parameters Directive in the script:

/proper or /pr=0/1
/properconstants or /prc=0/1
/updatevars or /uv=1/2/3

/tabchar or /tc=0
/gen_doc or /gd
/r_empty_lines or /rel 
/r_extra_empty_lines or /reel 
/showconsoleinfo=0/1/9 or /sci=0/1/9
/gen_doc_show or /gds
/showdiffpgm=xyz.exe
"%new%" "%old%" or /sdp=xyz.exe"%new%" "%old%"
/noshowdiffpgm or /nsdp
/keepnversions=n or /kv=n
/backupdir=directory or /bdir=directory
/Skip_commentblock or /scb
/Skip_EndFunc_Comment or /sefc
/Remove_EndFun_comment or /refc
/Skip_EndRegion_Comment or /serc
/Region_Indent or /ri
/Remove_Endregion_Comment or /rerc
/Sort_Funcs or /sf
/Sort_Funcs_Comment or /sfc
/End_With_NewLine or /ewnl


There is an example ini file in the folder to serve as a template:

Setting Tidy's options (Tidy.ini):

[ProgramSettings]
 * * *  Indent  0 = Tabs  >0 = Number of Space
tabchar=0

 * * *  Update Functions/Keywords/Macros/UDFs to Proper case
proper=1

 * * * Update Constants defined in the "constant Include files"
properconstants=0

 * * *  Update Variables to: 1=UpperCase; 2=LowerCase; 3=First Dim/Local/Global or "First_Seen" Case
vars=3

 * * *  Update Spaces around Delimiters
delim=1

 * * *  Add comment to EndFunc statement e.g. "EndFunc   ;==>UDF_Name"
#~ endfunc_comment=1
 * * *  Ignore EndFunc statement comments.
#~ endfunc_comment=0
 * * *  Remove comments from EndFunc statement.
#~ endfunc_comment=-1

 * * *  Added comment to EndRegion and make it the same as the #Region Comments.
#~ endregion_comment=1
 * * *  Ignore EndRegion statement comments.
#~ endregion_comment=0
 * * *  Remove comments from EndRegion statement.
#~ endregion_comment=-1


 * * *  Indent #region sections
region_indent=1

 * * *  Generate Documentation file for the Program and optionally Display it with Notepad at the end ot the Tidy run
Gen_Doc=0
Gen_Doc_Show=0

 * * *   Keep x Version of the File before the Tidy run and optionally store them in SubDirectory "\Backup"
KeepNVersions=5

 * * *   Target backup directory which defaults to Scriptdir\Backup. Any other directory needs to exist or else it will use the default directory!
backupDir=

 * * *   Remove Empty lines from Script Source
Remove_Empty_Lines=

 * * *   1=Show Tidy Errors in Console   9=Debug Output
ShowConsoleInfo=

 * * *   Run DIFF program at the end of the Tidy run to show the difference between original and new program.
xShowDiffPgm=C:\Progra~1\WinMerge\winmerge.exe "%new%" "%old%"

 * * *  End With NewLine: 0=Strip Lastline CRLF (default) 1=Always end with CRLF
End_With_NewLine=0