Changing my mindset

My issue has always been with trying to maintain the weight i lose & healthy habbits. I've been almost every size :| yoyoing up and down that I'm sure my body doesn't know what to do anymore!
After years, I'm still trying to figure out how to shift my mindset to encourage longevity and make this a lifestyle. I'm sure everyone has encountered hurdles in their journey, anyone managed to master it ?