I was not here when he came to see me.
I had not been here when he came to see me.
I left when he came.
I had left when he came. I had asked this type of questions before. But, even now I am not clear whether past or past perfect has to be used.
“I was not here when he came to see me.” correct.
"I had not been here when he came to see me." strange. I don't think it is necessary to use past perfect in this case.
"I left when he came." incorrect. There are two actions happened in the past stated in the sentence, one of which occurred earlier than the other. In this case, you must use past perfect to describe the one happened earlier.
"I had left when he came." correct.
Those are my understanding on the question and they may be wrong. I am waiting for others to give their input.
It depends on the actual situation. If A occurs before B, you should say, "I had left when he came." If A and B happened at the same time, you may say, "I was leaving when he came."
"I left when he came" is OK in day to day conversation, but I doubt your English teacher would approve it in formal writing.
Sorry, I only read 5jj's post after I had clicked on the reply button. (is it correct to use past perfect here?)