AutoTrim

Determines whether legacy assignments like Var1 = %Var2% omit spaces and tabs from the beginning and end of Var2.

AutoTrim, OnOff

Parameters

OnOff

Specify one of the following words:

On: In a legacy assignment like 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.

[v1.1.30+]: The decimal values 1 and 0 may be used in place of On and Off, respectively.

Any literal tabs and spaces are omitted regardless of this setting. Prior to [v1.1.06], this included `t and any escaped literal spaces or tabs. For example, when AutoTrim is Off, the statement Var = `t assigns a tab character on [v1.1.06] and an empty string on earlier versions.

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).

SetEnv

Examples

Disables the automatic omission of leading and trailing spaces and tabs when assigning a variable using the equals operator.

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.