The past decade has witnessed a quantum revolution in the field of computation, communication and materials investigation. A similar revolution is also occurring for free-electron based techniques, where the classical treatment of a free electron as a point particle is being surpassed toward a deeper exploitation of its quantum nature. Adopting familiar concepts from quantum optics, several groups have demonstrated temporal and spatial shaping of a free-electron wave function, developing theoretical descriptions of light-modulated states, as well as predicting and confirming fascinating phenomena as attosecond self-compression and orbital angular momentum transfer from light to electrons. In this review, we revisit the milestones of this development and the several methods adopted for imprinting a time-varying phase modulation on an electron wave function using properly synthesized ultrafast light fields, making the electron an exquisitely selective probe of out-of-equilibrium phenomena in individual atomic/nanoscale systems. We discuss both longitudinal and transverse phase manipulation of free-electrons, where coherent quantized exchanges of energy, linear momentum and orbital angular momentum mediating the electron–light coupling are key in determining their spatio-temporal redistribution. Spatio-temporal phase shaping of matter waves provides new routes toward image-resolution enhancement, selective probing, dynamic control of materials, new quantum information methods, and exploration of electronic motions and nuclear phenomena. Emerging as a new field, electron wave function shaping allows adopting familiar quantum optics concepts in composite-particle experiments and paves the way for atomic, ionic and nuclear wave function engineering with perspective applications in atomic interferometry and direct control of nuclear processes.