Even when we grow under grow lights and take every precaution we can, our tomatoes still get leggy. But that's not the end of the story for the tomatoes, nor do we have to dig an ultra deep hole to accommodate that long stem. Tomatoes are a vine and naturally will get 'leggy' at every opportunity. Most people stake up their tomatoes one way or another. We tie ours to baling twine and then tie the twine to tall supports. For our smaller tomatoes, like Cherries, we tie them to our deck. It's a pleasure to come out and nosh on them whenever we like.
If the tomatoes got too leggy before planting, we trench them. Tomatoes have tiny hairs all along their stems. When they vine naturally, on the ground, where ever a hair touches, a root can grow. We take advantage of this in trenching and the result can be much stronger plants in your garden. First, pinch off all the leaves up to the top three or four, be careful not to bend the stem too sharply or it will break. If it does, don't panic, just plant it anyway, a lot of times, the tomato will come back from it.
Dig a trench that is about five inches deep and scatter a tablespoon of Epson salts along the bottom of the trench. This adds potassium to the soil and that's good for tomatoes. Lay the tomato along the bottom of the hole. Gently bend the leafy end up and out of the trench. Heap soil around the stem, all the way to the root ball. If you plant in paper pots, like I do, then just bury the pot, too!
If you are going to tie your tomato to a trellis, now is the time to tie on the string. Make a very loose knot, as the tomato grows, this part of the stem will be a lot larger. Also, don't tie the twine to the support at this point. Just let it dangle until the plant gets it first branching so that you don't damage that tender stem. As the plant grows, wind the twine around the stem gently for support.
Cover your plant completely in rich compost and water amply for the first few days. It'll look peaked for a few days but should recover swiftly. Your work will be rewarded later on this summer with a bumper crop of delicious homegrown tomatoes