Previous Top Next

Tidy functions

Tidy can do all or any of the following

Example 1 - Standard indentation and capitalisation:


Example 2 - Simple syntax Check:


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:
Use this directives to set the inline comment column to a fix column going forward, use 0 to use the current column again:

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
"%new%" "%old%" or /sdp=xyz.exe"%new%" "%old%"
/noshowdiffpgm or /nsdp
/keepnversions=n or /kv=n
/backupdir=directory or /bdir=directory
/Tidy_commentblock or /tcb

/tcb=0               =>only indent the whole commentblock  (default)
/tcb  or /tcb=1 =>Tidy inside commentblock
/tcb=-1              =>leave whole commentbock alone

/Skip_CE_Comment or /scec
/Skip_EndFunc_Comment or /sefc
/Remove_EndFunc_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

/portable   (will force tidy to use the tidy.ini in the program directory)

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

Setting Tidy's options (Tidy.ini):

#-->Indent  0 = Tabs  >0 = Number of Space
#-->Define the TabSize size
#-->Update Functions/Keywords/Macros/UDFs to Proper case

 * * * Update Constants defined in the "constant Include files"

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

#-->Update Spaces around Delimiters

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

#-->Add comment to EndRegion and make it the same as the #Region Comments.

#-->Add comment to #CE/#CommentEnd and make it the same as the #CS/CommentStart Comments.

#--> Tidy commentblock 0=only indent the whole commentblock  (default=0)
#                                  1=Tidy inside commentblock
#                                 -1=leave whole commentbock alone

#-->Ignore EndFunc statement comments.
#~ endregion_comment=0
#-->Remove comments from EndFunc statement.
#~ endregion_comment=-1

#-->Indent #region sections

#-->Define the default column for inline comments, 0=keep current position

#-->Generate Documentation file for the Program and optionally Display it with Notepad at the end ot the Tidy run

#--> Keep x Version of the File before the Tidy run and optionally store them in SubDirectory "\Backup"

#--> Target backup directory which defaults to Scriptdir\Backup. Any other directory needs to exist or else it will use the default directory!

#--> Remove Empty lines from Script Source

#--> 1=Show Tidy Errors in Console   9=Debug Output

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

#--> End With NewLine: 0=Strip Lastline CRLF;   1=Always end with CRLF (Default)