What is #NOTRIM# for ? And using other MonoBehaviour template built-in magic variables.

I can understand what is: #SCRIPTNAME# for.
But I do not know #NOTRIM# is it for.
Are there more #FUNCTIONS# ? where to find them?

Here is an example using #NOTRIM# inside a Unity default template 81 C# NewBehaviour Script
https://gist.github.com/apkd/c111a0aba58500225c80e3ca4af9ef3d

A short answer from https://support.unity3d.com/hc/en-us/articles/210223733-How-to-customize-Unity-script-templates

What is this NOTRIM for and how to use it?

Does anybody know #NOTRIM# what is it for? Is inside the C# template.

I’m not sure either. I’m guessing that it’s there to prevent empty lines from being deleted depending on your operating system.

It doesn’t seem useful to me on a PC, so I don’t bother using it. It might be more useful on a MacOS system, but I have no way to verify this theory.

It doesn’t seem to have any effect on MacOS either.
I just tested with Unity 5.6.1 and MonoDevelop 5.9.6.

You just answered your own question in your first post…

In the MonoBehaviour template it preserves the indenting inside the empty functions. the auto-trimming of white-space may be platform or IDE specific, so #NOTRIM# likely can help standardize that. so that the intended behavior is consistent. Honestly #NOTRIM# is likely a noop. but simply cause its there it indirectly prevents the parser from clearing that line.

Thats all its for. automatically setting indentation within the function.

2 Likes

is there a list of other placeholders?

Not really. And there is not much to it.

https://github.com/Unity-Technologies/UnityCsReference/blob/2d9918cf6dc3194015d75bd9845555f59a0015e4/Editor/Mono/ProjectBrowser/ProjectWindowUtil.cs#L613

  • #NOTRIM#
  • #NAME#
  • #SCRIPTNAME#
  • #SCRIPTNAME_LOWER#
  • #ROOTNAMESPACEBEGIN#
  • #ROOTNAMESPACEEND#

And that’s it.
I also wrote this package: https://github.com/LurkingNinja/com.lurking-ninja.csharp-templates
It’s easy to extend to introduce new, whatever markers you like, although you will have to change the source code if you want.

1 Like