Our universe is threaded by billions of galaxies organised in walls, filaments and clusters. The Cold Dark Matter theory is very successful at predicting the dynamics of cosmic structure on large scale. Within the same model, we also want to predict the rich variety of galaxy shapes and colours, a much more challenging endeavour. I will present the current status of the theory of galaxy formation, with an emphasis on small scale physics, such as star formation and the associated stellar feedback. I will show that gas turbulence in the interstellar medium is likely to play a key role. I will finally describe one current frontier in computational galaxy formation, namely the modelling of magnetic fields and their possible impact on the structure of galaxies.