Actually, it's a little more complicated than that. There are a few situations when you can do this, but it usually makes the tenant worse off. So, it's almost always best to keep paying rent! If you stop paying, your landlord may file for eviction and eviction cases move pretty fast. You can bring up the fact that your landlord hasn’t been making repairs in eviction court. But, you won't have a lot of time to get your evidence together and you usually have to be able to prove that your landlord had notice of the problems at least 14 days before the rent you didn’t pay came due.
Usually, it's best for you to be the one filing a case in court if it comes to that.