We study the role of stellar feedback in the formation of galaxies in a LCDM Universe. Our main tools are cosmological hydrodynamical simulations with a maximum resolution of about 50 pc. We also use hydrodynamical simulations of the ISM to resolve the effect of star formation and stellar feedback in a global ISM. The injection of energy from stellar winds and supernova explosions maintains the hot phase of the ISM. This phase is characterized by high gas temperature ( 10^6 -
10^8 K) and low densities (10^-4 - 10^-2 cm^-3). This hot gas is found in bubbles, super-bubbles and chimneys perpendicular to the galactic plane. We also found that the injection of energy from massive runaway OB stars in the diffuse ISM should be taken into account in order to model accurately stellar feedback. After we tested our model at ISM scales, we applied the same model in cosmological simulations of galaxy formation. Our results indicate that stellar feedback can suppress the formation of a massive bulge. However, a resolution of about 60 pc and the effect of runaway stars are both necessary in order to resolve accurately the effect of stellar feedback in cosmological simulations.