I'm not sure of that. I know that I was able to leave my Pikmin out and go in a cave when I did my no-death run, but that was always right after they brought a treasure to the base. Does anyone know for sure? I can't test it at the moment.--Prezintenden

I just tried it, actually. Any Pikmin left idle when you enter a cave, no matter how far from the landing site they are, will return to their Onion safely. —Jimbo Jambo