Try pasting in the code which you know won’t work and then delete the spaces and put those back in again in the template editor manually. See if that works and if that doesn’t then try manually deleting (again all the time doing this in the ExpressionEngine template editor) the colons and retest and then the curly braces. The fact that you paste it into notepad and then copy-paste must mean that somewhere the code is getting converted in some way or another. Just need to find out which part is tripping it up then hopefully there’s a reason for it which can be found out and fixed.
Best wishes,
Mark