# Tidy | Previous Top Next

## Tidy functions

Tidy can do all or any of the following

- Clean up the indentation with either spaces or Tabs (use SciTEConfig to select which).
- Change all Functions/Keywords/Macros to proper case as defined in the configuration files
- All user functions and all Func definitions in the script are loaded into the Functions table. This option only works in combination with the previous option.
- Standardize all variable names to uppercase, lowercase or as capitalised at the first declaration/occurrence
- Add a space or remove additional spaces around operators/keywords/functions.
- Remove empty lines.
- Remove trailing spaces.
- Add the function name as a comment after EndFunc to identity which Func ends at that point
- Generate a Documentation file with program logic and Xref reports for Variables and UDF's.
- Check for coding errors like missing EndIf/WEnd or defining a Func inside a loop.
- Sort all Func-EndFunc blocks in alphabetical order limited by #region-#endregion blocks if used

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:
#Tidy_Off
#Tidy_On
Use this directives to set the inline comment column to a fix column going forward, use 0 to use the current column again:
#Tidy_ILC_Pos=nn
#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 /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

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 #-->Define the TabSize size tabsize=4 #-->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 #-->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. endregion_comment=1 #-->Add comment to #CE/#CommentEnd and make it the same as the #CS/CommentStart Comments. ce_comment=1 #--> Tidy commentblock 0=only indent the whole commentblock (default=0) # 1=Tidy inside commentblock # -1=leave whole commentbock alone Tidy_commentblock=0 #-->Ignore EndFunc statement comments. #~ endregion_comment=0 #-->Remove comments from EndFunc statement. #~ endregion_comment=-1 #-->Indent #region sections region_indent=0 #-->Define the default column for inline comments, 0=keep current position ilc_pos=0 #-->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. #~ ShowDiffPgm=C:\Progra~1\WinMerge\winmerge.exe "%new%" "%old%" #--> End With NewLine: 0=Strip Lastline CRLF; 1=Always end with CRLF (Default) End_With_NewLine=1

https://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/Tidy.html