The general consensus is to not use colors.
However, this also depends on the field.
Some fields, particularly in computer science, have accepted the use of colors for sake of readability.
The following does not only hold for papers, but also for presentations, since accessibility at conferences or workshops should also be considered.
If you really want to add colors to your work, some care must be taken.
As the other answers have indicated, using colors to convey important information can seriously impede the experience for the color-blind.
It really depends on what colors you choose. You can choose colors that any type of colorblind people can still distinguish.
To make sure you use the right colors, use a tool like Sim Daltonism.
In order to distinguish on black-white print, it's advisable to add additional emphasis/use different fonts, e.g. the blue one is bold, the other, green one cursive, the next, orange one is underlined.
That way, people with monochromatic vision and people who read your work on a black-white printout can still benefit from your highlighting.
That said, depending on how adopted the use of colors is in your field, you might have more trouble than good if researchers, and ultimately referees, are not used to it and strongly oppose to the use of syntax highlighting, despite its benefits and, if done rightly, accessibility. To try to remedy this, you should add a line to your paper that says "This paper uses colors. While still readable as a black-white print, for an enhanced experience, view this paper in colors."
Concluding, yes you do can use colors in your paper. However, do so in a sensible manner that keeps the accessibility. Nevertheless, you should really ponder whether the inclusion of colors+font diversification is actually beneficial to your work after all.
As a personal judgement from your screenshot, the current choice of colors and fonts makes it much more difficult to read than without colors. You should abstain from using a hard blue or a hard red on black background.