Heterocycles' aggregates show rather good proton conductivity. In particular, condensed structures formed by imidazole rings that are held together by polymeric chains have attracted some interest as possible candidate materials for fuel cell membranes. However, the details of the proton diffusion process could not be resolved by means of experimental measurements because of the fast rearrangement of the structure after each proton exchange. In this work, we report in detail the results of ab initio molecular dynamics calculations, which were briefly presented in a previous Letter [M. Iannuzzi and M. Parrinello, Phys. Rev. Lett. 93, 025901 (2004)]. The conformational changes associated with the diffusion of protons in model crystalline structures containing chains of imidazole rings are described in the framework of an atomistic approach. In particular, the bonding pattern characterizing the structure of imidazole-2-ethylene-oxide doped by an excess proton is also studied through the calculation of the 1H NMR chemical shifts. The unresolved resonances appearing in the experimental spectra could be associated with specific structural features, in connection with the fluctuating hydrogen bonding. The analysis of the distortions that induce or are induced by the mobility of the protons offers some new hints for the engineering of new proton conducting materials.