Enscript[1] is my (the?) preferred way and a plugin would be a fine tay to achieve this. Will format code in almost any way you could ever imagine.
1: https://www.gnu.org/software/enscript/
Reply on news.ycombinator.com