This is totally normal. During recovery, your hunger cues are unpredictable and you might get huge cravings for carbs & simple sugars. (The need to eat carbs is why most recovering anorexics become bulimic so please be careful. Don't deny, restrict food or feel bad. Once you are weight restored then the huge cravings won't be so much.) Just remember these carvings are normal and happen to many people going through recovery.
However, simple sugars are high in carbohydrates and cause a surge in insulin levels which can cause fluid retention. Try to slowly switch over to complex carbohydrates: grains, cereals, fruits and vegetables.
It's not a bad habit that you have to give up. Once you are weight restored then you will get a new meal plan and you start all over working on how to follow it.
For right now, your body is undernurished so make sure you are following a meal plan. I had a lot of weight to gain and I mostly ate carbs, protein and to gain weight I ate food that wasn't healthy after each meal.
Good Luck and don't give up!