Leggy tomatoes aren’t a problem. Tomatoes grow roots from any part of the stem that touches soil, so you can plant them deep, leaving a few leaves above ground, and they will grow normally. I have heard mixed messages about doing this with peppers (which are related) but you can’t do this with other plants.
Good luck.
nacl