You've gotten a lot of good answers about distance . . . my criterion is that I don't get further away than I can clearly see my buddy, and never further than I want to swim for gas (which I've tested, and is about 20 to 25 feet).
But I'd like to address the use of lights. When I dive in Puget Sound, I'm often not more than four or five feet from my teammates. They are roughly side by side with me. But we all have lights, and instead of looking from side to side to find them and see how they are doing, I can just watch their lights out in front of me, where I want to be looking anyway. If the lights are there, and are making a normal kind of "looking for critters" sweep, then I know I have two nearby buddies who are fine. If the light goes missing, or begins to be erratic, I know something isn't right, and I can then physically turn and see what's happening.
Similarly, if we are diving the hull of a wreck or along a wall, where going single file means everybody gets to see more, the lights keep us in contact, and nobody has to look through his legs or crane around to stay in contact.
So the use of lights doesn't mean we open up big separations between divers. It just means that we stay in touch without having to look around nearly as much. Lights don't work for this very well in extremely clear, sunlit water. But in low viz or in the dark, they rock.