During Sanji's flashback, he seemed convinced that Zeff and his men were going to kill them all, when Zeff had only given an order to take everything of value. The panels depict his crew robbing people forcefully, but no scenes of the crew and captain being butchered. So why would Sanji think that the pirates were murderers when all they'd proven themselves to be, up to that point, were thieves? Maybe he was just a kid who overreacted. Or maybe he'd had experience with pirates before.
This is major speculation, and a work of complete fiction until Oda fleshes out Sanji's past–if he ever does.
I think that when Sanji was very young, say five or six years old, his home was attacked by pirates. While looting the town, they messily killed everyone in their path. When they got to Sanji's house, it was only he and his mother there, his father having been killed or lost sometime earlier. To save her only son, Sanji's mother (until a name is provided) sacrificed herself. Even after being cut down, she continued to plead with her killer to spare her son. This infuriated the lout, who proceeded to beat her to death. Sanji made a hasty retreat, his mother's dying words "Run, Sanji! You have to live!" seared into his brain along with the image of a man brutalizing a woman in the cruelest manner possible. Afterwards, pirates were scum to him.
But Zeff changed his attitude, somewhat. The old fart taught him that being a pirate wasn't an excuse for plunder and bloodshed--it meant living life by your own rules, not giving a damn what anyone else thought. Being a pirate meant giving everything for your dreams and dying for your convictions, if necessary. And if there is one theme that sums up the philosophy of One Piece, it is conviction.
Luffy's conviction to become Pirate King, no matter what hardships he might endure, Nami's conviction to free her village, no matter how much Arlong made her suffer, Usopp's conviction to become brave, even when he's so scared that he runs away screaming, and so many more. So it really comes as no surprise that Sanji should have such conviction in his feelings. Friendship? Sure, having friends makes it worthwhile, but if you don't have convictions, you're not worthy of the respect it takes to have friends. If that offends you, well good; that's one of my convictions.
Indeed, it is when conviction falters in One Piece that characters fall into selfish behavior, rationalizing how their actions are merely reducing collateral damage, when in truth, they are destroying everyone they care about. Nami's plea to the people of Cocoyashi to endure a while longer after Nezumi stole her treasure, Usopp's insulting words to Luffy and the fight that followed, Robin's betrayal of the crew, all of these actions were motivated by a desire to protect their own ideals. Nami didn't want her own suffering to have been for naught, Usopp didn't want to face the thought of being too weak to continue the journey and being abandoned, and Robin couldn't stand the thought of another betrayal, particularly by people with such open faces and hearts. They had all lost faith in their ability to achieve their dream, and when that dream died--Cocoyashi's freedom, status as a brave warrior, the secret of the 'Lost History'-- they became bitter and selfish. Sure, its saddening to see the character we've come to love be so bastardly, but it is the negative traits which flesh them out as characters, give them depth, and make us love them more when they get up and become the strong, loving crew that any one of us would love to call nakama.
So it is that I have high hopes that Sanji will rise again, do something heroic and badass, and at the same time not brutal toward the fairer sex. Because as much as its a shame to see him abandon Robin to stick by his code, it would be worse to see him abandon everything he believes in and start to become a total jerk.