Coral reef fishes are diverse in ecology and behaviour and show remarkable colour variability. Investigating the visual pigment gene (opsin) expression in these fishes makes it possible to associate their visual genotype and phenotype (spectral sensitivities) to visual tasks, such as feeding strategy or conspecific detection. By studying all major damselfish clades (Pomacentridae) and representatives from five other coral reef fish families, we show that the long-wavelength-sensitive (lws) opsin is highly expressed in algivorous and less or not expressed in zooplanktivorous species. Lws is also upregulated in species with orange/red colours (reflectance >520 nm) and expression is highest in orange/red-coloured algivores. Visual models from the perspective of a typical damselfish indicate that sensitivity to longer wavelengths does enhance the ability to detect the red to far-red component of algae and orange/red-coloured conspecifics, possibly enabling social signalling. Character state reconstructions indicate that in the early evolutionary history of damselfishes, there was no lws expression and no orange/red coloration. Omnivory was most often the dominant state. Although herbivory was sometimes dominant, zooplanktivory was never dominant. Sensitivity to long wavelength (increased lws expression) only emerged in association with algivory but never with zooplanktivory. Higher lws expression is also exploited by social signalling in orange/red, which emerged after the transition to algivory. Although the relative timing of traits may deviate by different reconstructions and alternative explanations are possible, our results are consistent with sensory bias whereby social signals evolve as a correlated response to natural selection on sensory system properties in other contexts.