NOT AN ATTORNEY
If you think you’re going to be involved in a custody battle, document, document, document, starting now. (Same thing goes for the separation/divorce itself.) In this case, things that will help you for the custody situation are evidence that supports you being the parent more involved in the child’s life. Evidence that you are the primary person who: attends parent/teacher conferences, take the child to/from school or activities, take the child to doctor/dentist appointments, misses work to take your child anywhere or care for them while they are sick. Additional things that may help are evidence proving that your work schedule is more flexible to care for the child’s needs, testimony from family friends, teachers, physicians who have seen you interact with the child. It also helps to find any evidence that supports the idea that you are the parent most likely to facilitate contact with the other parent and less likely to be vindictive and withhold contact between the other parent and their child. (e.g. any threatening emails that may come to you where your STBX says that he’ll take the child from you in a custody battle.)
Other than that, yes, file for temporary custody and child support the moment you move out. Be prepared for any reaction and try to communicate only through forms that can be documented easily in court. Whether or not you use it, sometimes just the knowledge that one’s words can be used against them can help them behave a bit better or beware what they say.