Vertebrate locomotion is due to the interplay of neural oscillators and sensory feedback loops in the spinal cord that interact with the body and the environment. Here, we study these circuits with a focus on undulatory locomotion as produced by elongated fish such as eels and lampreys. We address three questions: i) How do proprioception (stretch feedback) and exteroception (pressure on skin) interact with local oscillators to generate stable swimming patterns? ii) Can these feedback loops also contribute to dry ground locomotion? iii) Can they explain the remarkable robustness of eels against spinal cord transections? To address these questions, we developed abstract models of the locomotion circuits based on coupled phase oscillators, local stretch and pressure feedback loops, and simulated muscle models that were tested both in simulation and with a real undulatory robot. We also performed swimming experiments with eels before and after spinal cord transections. We found that stretch and pressure feedback work well together in swimming, as they contribute to rapid pattern generation and can, in principle, both replace direct couplings between oscillators. Interestingly, the swimming controllers could generate good ground locomotion when placed in an arena with pegs. For ground locomotion, the stretch feedback is more beneficial than pressure feedback. Finally, our models could replicate the remarkable ability of eels to keep swimming shortly after a full spinal cord transection. We found that stretch feedback and the ability of oscillators to spontaneously oscillate are likely explanations for keeping the neural oscillators active and coordinated below the transection.