Please indulge my ignorance... Maybe a chemist or someone better versed can answer; are we close, or is it plausible to construct a star trek like replicator to rearrange atoms to form new substances such as water?
But who knows. Maybe when society is so advanced that we have infinite power from controlled fusion, extremely accurate and high powered lasers and magnetic field generators, and quantum computers, we'll be able to build a box that moves around individual atoms to construct something.
Though that doesn't mean that nanotechnology is impossible. In fact, nanomachines in the form of microbes precede any macromachines. We are getting better and better at controlling microbes. Though we won't be able to use genetic programming on microbes alone to make a cake or steak from scratch.
You can form water from recombining oxygen and hydrogen. Or from material that contain oxygen and hydrogen.
Making water out of anything else, is possible in molecular quantities at an exorbitant price using a particle accelerator (or so). So in practice, impossible.
A Star Trek Replicator, even one that doesn't transmute different elements into each other and just re-arranges them, is a long way off. The best current design we have is called an ecosystem and uses plants, fungi, animals, other life forms and sun light.
To mostly mirror what eru said, we can easily combine hydrogen and oxygen just by burning them together.
You can also extract amounts of oxygen and hydrogen from more complex substances and turn them into water through the magic of that science we know as Chemistry. You should expect that this will generally take a bunch of energy, though.
Nanotechnology has the potential to let us construct much more complicated sorts of chemical structures. It would be really neat, but wouldn't really change how much energy it takes to separate water out of other materials, and would probably be a lot less energy efficient than standard industrial methods.