If you have a leg cramp in your calf, stretch the muscle by standing on both feet with bent knees. If pain prevents you from standing, sit in a safe location and bend your ankle toward your shin, raising your foot toward your kneecap. Use your hands to pull your foot gently toward your shin if you cannot voluntarily move your foot. For a cramp in the front of your thigh, brace yourself against a sturdy object and bend your knee while gently pulling your heel toward your buttocks. You can also perform this stretching maneuver while lying on your side. If you develop a cramp in the back of your thigh, raise your straightened leg forward with your ankle bent toward your shin. Try resting your heel on a stair or another sturdy raised object to help with your stretch
Everyone's right ^ about making sure you're not dehydrated, and that you have enough potassium, and how to stretch a cramp out when you get one. But I've learned something else that really helps: get the weight of the blanket off your legs and feet. I put a bolster under my blanket, all the way down at the foot of my bed. It lifts up the blanket just enough that I don't feel any weight or pressure. My blanket isn't very heavy, so this sounded like a dumb idea when I first heard about it from a friend who's a nurse, but I haven't had any leg cramps since I started doing this, and I used to get them almost every night. Hope this helps you, too.
I get leg cramps in the summer....usually because I've not had enough water during the day and not enough potassium. So to help with this, I eat at least one banana a day and try to drink as much water ass possible. Potassium is in all types of food though, so if you do not like bananas, try one of them. Here is a list of potassium rich foods: