A habit is an action or behaviour that we do automatically and regularly, without consciously thinking about doing it. This behaviour is associated with some cue that initiates the habit. We learn our habits: I am old enough to remember the 1970s when we didnt have to wear seatbelts. But after it became something we had to do, people gradually got into the habit of automatically reaching for the seatbelt when they got into a car. Here the cue is environmental and external: sitting in a car. But the cue could be internal and emotional, so feeling anxious might be the cue that triggers the habit of biting your nails.

Source: How long until exercise becomes a habit? · The UK’s leading Sports Psychology Website