They have been doing it for a long time, they have poured a lot of money and effort into finding alternative energy sources over the past decades and as a result, we have wind power, solar power, or electric cars. But the problem is that they are too expensive and the technology is still too limited. So I don't think the era of crude energy like oil and gas will be a thing of the past anytime soon, maybe even ever.
The human world has been dependent on these fossil energy sources for thousands of years, not just a few hundred. Therefore, it would probably take millennia to replace them, not centuries or decades.
At some point, all of the world's fossil energy sources are going to run out. Many predict that will happen by the year 2052. That's only 27 years away. Either the world finds a viable alternative to oil, or chaos will ensue. Besides wind and solar energy, we also have nuclear energy. The world's first fusion reactor is being built in France, promising a cleaner and safe alternative to existing fission reactors. If countries start building such reactors in-mass (emphasis in "Fusion" not "Fission"), all of our energy problems will be solved.
As for vehicles, they can run on hydrogen which last longer than lithium-ion batteries (used by EVs). Toyota is building cars with this tech. With all of this, the oil industry will become history. I understand there's a lot of money involved in oil (big, wealthy companies don't want the oil business to end), but sooner or later, everyone is going to have to find an alternative. Unless, there's plenty of oil that would last for "millennia" like you've said. Only time will tell...