How to distinguish between 为 and 给 when both means "for"
My feeling is:

That 给 is for doing something ''for'' someone.

I will buy it for you. 我给你买。

You will do the verb for someone else.

And 为 is more abstract

I am sad for you. 我为你伤心。

I'm not native but I don't think you could say:

我为你买东西。  X

我给你伤心。   X