Determines whether "Var1 = %Var2%" statements omit spaces and tabs from the beginning and end of Var2.
AutoTrim, On|Off |
Parameters
On|Off | On: In a statement such as Var1 = %Var2%, tabs and spaces at the beginning and end of a Var2 are omitted from Var1. This is the default. Off: Such tabs and spaces are not omitted. However, any literal tab and spaces (including `t) are omitted regardless of this setting. For example, the statement Var1 = `t%Var2% always ignores the `t character. To prevent this, use one of the following: Var1 = %A_Tab%%Var2%%A_Space% ; AutoTrim must be OFF for this to work. Var1 := "`t" . Var2 . " " ; The setting of AutoTrim doesn't matter because this is an expression. |
Remarks
If this command is not used by a script, the setting defaults to ON.
The built-in variable A_AutoTrim contains the current setting (On or Off).
The built-in variables A_Space and A_Tab contain a single space and single tab character, respectively.
AutoTrim does not affect expression assignments such as Var := " string ". In other words, leading and trailing spaces and tabs are always retained in such cases.
Every newly launched thread (such as a hotkey, custom menu item, or timed subroutine) starts off fresh with the default setting for this command. That default may be changed by using this command in the auto-execute section (top part of the script).
Related
Examples
AutoTrim, off NewVar1 = %OldVar% ; If OldVar contains leading and trailing spaces, NewVar will have them too. NewVar2 = %A_Space% ; With AutoTrim off, a single space can be assigned this way. Var1 := "`t" . Var2 . " " ; The setting of AutoTrim doesn't matter because this is an expression.