How Edward managed to escape from Gluttony? In Episode 24 and 25 of Fullmetal Alchemist: Brotherhood, Ed, Ling Yao and Envy are trapped in a sub-dimension that was created for storing everything that Gluttony has ever swallowed.

Envy told that there's no escape, but Ed has found out something. What did he do exactly?

As far as I can get, he did human transmutation to open the Gate of Truth and by this, he can escape. But how is it possible? Since the sub-dimension is separated from the actual world.

Also, why Ed didn't lose anything when he opened the Gate again? Why Envy and Ling neither?
Gluttony was created to be a second Gate of Truth but is only a failed copy. Ed had the idea that because they came there through the failed gate, they must be able to get back trough the real gate. It's just like creating a door back to Gluttony.

To open the Gate of Truth, he used Envys Philisopher's Stone and the old parts of the Xerxes mural to make this special human transmutation. The sacrifice for opening the gate was a soul of the Philisopher's Stone, which thanked him afterwards (because he freed the soul).