You first get the ability to switch gravity in C1-1. I found the best first place to stay in a continuous loop was C2-2.
All you need to do is time the gravity flips with
. There is a blue sign on the wall to the left when you start. Press
, then every time you pass the sign, press
again. This will keep you falling back and forth. After ten, you should be falling away from where you started, so mash
until you flip back again and land safely.