So do any of you think it's possible to talk to him (or write a careful letter) and set a boundary between acceptable and unacceptable mode of conversation? Or is running away the only option? I mean, he is respectful with other students. He is like this only with those that are closest to him.
I am also afraid that if I don't learn to stand up for myself here, another situation will present itself elsewhere and I will be forced to run from other dojos, jobs, relationships, etc...
I don't think writing a letter would do any good at this stage. I'm not intimately familiar with the situation, but from what you have said, it sounds like you are in an abusive relationship. Writing a letter might improve things for a while, but only long enough for him to convince you that things aren't all that bad and maybe you should stay. After that, the cycle will most likely repeat itself.
In what way is leaving not standing up for yourself? To me, deciding to leave a situation that is making you unhappy and destroying your self confidence is a good way to stand up for yourself. If it makes you feel better, write your sensei a letter to tell him why you are leaving (but whatever you do, don't give him a chance to respond). Staying in the situation is not standing up for yourself, it is merely punishing yourself. Leaving is not running away, it is merely choosing a better option.
There are many good aikido teachers out there, and they do not treat their students like crap. You mentioned uchi-deshi being treated like crap in the old days. Well, I'm pretty sure that being treated like crap didn't make them better at aikido. It was merely the way things were done back then, particularly in Japan. We are talking about the period of time around WW2 when young men were expected to crash their planes into the enemy for the good of the country, and doctors were expected to perform vivisections on POWs. At that point in time, a lot of people were treated like crap with no good reason.
Your teacher may expect you to train hard, even to the point of exhaustion. He may expect you to make sacrifices in terms of your free time. He may challenge you to face your fears. What he may not do is yell at you, insult you, and take away your self-esteem. That is abuse, and there is no excuse for it.