Printing code with syntax highlighting?

后端 未结 13 2233
轻奢々
轻奢々 2021-02-01 16:00

I have occasion to need to print code (Horrors!!! ;) ), and i was wondering what editor or tool would i use to print that code out with proper formatting and syntax highlighting

13条回答
  •  滥情空心
    2021-02-01 16:34

    You can use Vim! It's probably installed already if you're on modern Linux/MacOS and an easy install if not.

    :syntax will turn syntax highlighting on and :hardcopy will print it. There's syntax highlighting definitions for many languages out there. The default look is usually optimised for screen display, but you can fix that.

    Simply open the file on command line with vim , type :syntax on, then :hardcopy to print it. Quit Vim with :q!.

    There's also the :TOhtml command which will open the current selection as HTML in a new Vim window. Capture the entire document with :%y followed by :TOhtml to open it.

提交回复
热议问题