The trick is to find something else to do with your mouth or hands, to keep them away from each other. Something easy that you can pick up and do on a whim. Like, I don't know, knitting or something? I can't think of a good example to occupy hands - my brain isn't working. But chewing gum is a great way to occupy your mouth, and you can work out your stress on that piece instead of on your nails.
Ooh, another thing that might help. Paint your nails with colored polish. It looks terrible when it's all bitten up, so it might help keep you from biting them.
Karin: I used to bite my nails down to the quick, and sometimes accidently go lower than that. It was horrible. I would hide my nails too.