Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim different color scheme when printing

Tags:

vim

Is there a way in _vimrc to set a different colorscheme to be used when printing files?

I like a dark background light text scheme on screen, but obviously that doesn't translate well to paper.

Edit: I can change the scheme manually before printing, then change it back after and it works fine. Just curious if there's a way to tell Vim to always use a specific scheme while printing.

This is what :hardcopy outputs: enter image description here

like image 642
Dan Bechard Avatar asked Mar 06 '14 17:03

Dan Bechard


People also ask

How do I permanently change vim color scheme?

How to Set Default Vim Color Scheme. Changes you have made to the color settings are not permanent. Once you close Vim, the color scheme returns to the default settings. To make the changes permanent, modify Vim's configuration file with the wanted color settings.

Where do vim color schemes go?

View preinstalled color schemes Some color schemes are already installed on your system. You can find those color schemes in the /usr/share/vim/vim*/colors directory as . vim extension.

How do I change the default color scheme in Gvim?

You can set your preferred color scheme in gvim for MS Windows by editing the file _vimrc in C:\Program Files\Vim or the location where you installed Vim. Save the file and start gvim you will see your color scheme.


2 Answers

How about something like

:command Hardcopy let colors_save = g:colors_name <Bar> colorscheme default <Bar> hardcopy <Bar> execute 'colorscheme' colors_save

Maybe throw in the 'bg' option. If you care about local variables, make it a function:

command Hardcopy call Hardcopy()
function! Hardcopy()
  let colors_save = g:colors_name
  colorscheme default
  hardcopy
  execute 'colorscheme' colors_save
endfun
like image 58
benjifisher Avatar answered Sep 30 '22 19:09

benjifisher


The Vim plugin "Printer Dialog" allows to configure printing parameters, one of them is the colorscheme to be used for printing.

After installing and configuring "Printer Dialog" press \pd in the Vim window you want to print. The following "dialog" will open:

enter image description here

Beneath other things the syntax-highlighting for printing can be selected. See :help printer-dialog for further details. The variable g:prd_syntaxList defines the syntax-highlightings that can be selected. Default is

g:prd_syntaxList = "no,current,default,print_bw,zellner" 

See :help prd_syntaxList for details on how to setup this feature.

like image 39
Habi Avatar answered Sep 30 '22 18:09

Habi