The molecular stacking in film state has been confirmed to have an important influence on electronic properties of organic semiconductors. Thus, how to improve the molecular stacking and the corresponding device performance through molecular design is a difficult question that researches want to figure out. In this work, three small molecules with different bridge-spacers, phenyl ring, pyridine, and pyrimidine, are designed to study the effect of nitrogen amount on molecular stacking in film state. The infrared spectroscopy in solution and film states are first measured to consider the hydrogen bond between the neighboring molecules, which can induce ordered molecular stacking through intermolecular interaction. X-ray diffraction, atomic force microscopy, and grazing incidence small angle X-ray scattering measurements confirm the ordered molecular stacking and crystalline orientation of nitrogenous heterocycles substituted molecules in film state. Additionally, nitrogenous heterocycles substituted molecules exhibit the excellent ternary data-storage properties with low threshold voltage and high current ratio. This result presents the strategy for designing novel small molecules with excellent molecular stacking in film state.