Pyridine and pyrimidine groups connected through amide functions can be combined into specific sequences that self-organize into either helical or linear structures enforced by the formation of intramolecular hydrogen bonds.