Printing from Vim colors too bright

Go To StackoverFlow.com

4

When I print from vim using :ha, everything is great, except yellow is freakishly bright. How to tell vim to darken the yellow when printing with :ha?

2012-04-05 22:36
by oFca
My best bet would be to change the color scheme before printing with po=syntax: - sehe 2012-04-05 22:38
@sehe you mean :set printoptions=syntax:y ? I've tried that, still ridiculesly bright.. - oFca 2012-04-05 22:40
Yes, either change the color scheme to a more printer-friendly-one, or use black&white color scheme for printing (i.e. disregard syntax highlighting) - Rook 2012-04-05 22:40
wich colorscheme do you suggest I use for printing ruby code? and how to install/set up that colorscheme - oFca 2012-04-05 22:42
@oFca no, I meant change :colorscheme when printing with syntax:y (conversely: print with syntax:n - sehe 2012-04-05 22:44
@sehe sorry, but I'm a bit slow, I don't understand... Can you please literally write what I should write in vim before typing :ha ? Also, I would like to solve this in my ~/.vimrc file, so if you know, write the line for that also - oFca 2012-04-05 22:54


3

I got the answer from some great guy in IRC at freenode.net. (rking if someone knows him :)

Anyway, this solution works perfectly for me. By pressing F12, it opens file I was editing in vim in browser (in the case below in chrome), and all I have to do is right click > print.

Anyway here's the code you should add to your ~/.vimrc file:

:map <f12> :TOhtml<cr>:%s/#ffff00/#aaaa00/g<cr>:w<cr>:!chromium-browser --print file://`pwd`/%<cr>:!rm %<cr>:q<cr>

Notice that you can specify the shade of the color you wish to change (in this case yellow) and modify it. It even gets rid of the duplicate file created by the :w command. Also, this code is modified for Ubuntu, with other OSs it might need some modification.

There is only one bug > !chromium-browser --print should print it automatically but it doesn't. I need to manually print it from the browser. Minor nuance, but if someone can solve this up, I would greatly appreciate :)

2012-04-06 17:24
by oFca
resourceful; not really a vim answer, but resourceful + - sehe 2012-04-06 21:24


2

If you are looking for a way to just print readable code, you might just

:set printoptions-=syntax:y
:set printoptions+=syntax:n

before you do

:hardcopy

Otherwise, you might choose a colorscheme without yellow(ish) colors before printing

2012-04-05 23:00
by sehe
Or set "grayscale" (or whatever it's called) in his print options. Most printers have that option nowadays - Rook 2012-04-06 00:52
@ldigas With my laser printer, the yellow would still not be very readabl - sehe 2012-04-06 08:19
i found the solution i was looking for. i posted it as the answer here : - oFca 2012-04-06 17:25
Ads