For an action that was going on for a while before a past moment, use had been + the -ing form.
had been + the -ing form
Lani: My laptop died last night. I'd been typing for three hours without saving.
Matilda: That happened to me once too.
Not "We had been wait for an hour.". Say "We had been waiting for an hour.". After had been, use the -ing form.
Try it: Diego: Did the storm ever stop? Wei: Yes, but by then we ___ under a tree for twenty minutes. Choose the words for the blank. (had been sheltering / were sheltering / have been sheltering) Answer: had been sheltering. Something going on for a while before a past moment takes had been sheltering.
Use had been + -ing to explain what you could see at a past moment, after an activity that had just stopped.
Lani: Why was your face so red when I came in?
Matilda: I'd been rushing around, setting up the room.
Try it: Mei: Why were Hiroshi's eyes so red at lunch? Sofia: He ___ all morning. The pollen was terrible. Choose the words for the blank. (had been sneezing / has been sneezing / will be sneezing) Answer: had been sneezing. Red eyes at lunch came from an activity just before: had been sneezing, not "has been".
hadn't been / Had you been ...?
For a negative, use hadn't been + -ing, and for a question, put had first: Had you been ...?
Lani: Had you been practicing your talk all week?
Matilda: No. I hadn't been feeling nervous until this morning.
Try it: Ethan: ___ you been waiting long when the doctor called you in? Mateo: About forty minutes. Choose the word for the blank. (Had / Did / Were) Answer: Had. A question about something going on before a past moment starts with Had.
had done or had been doing?
Had + the past participle shows something finished, while had been + -ing shows how long an activity went on.
Lani: When you called time, I had written two pages.
Matilda: And Ira had been drawing the whole time!
Try it: Yasmin: Did Lars finish the book before the trip? Choose Farid's reply. (Yes, he had read the whole thing before we left. / Yes, he had been reading the whole thing before we left.) Answer: Yes, he had read the whole thing before we left. A finished book takes had read, while "had been reading" shows the reading was still going on.