(Adjust previous/next navigation) |
(adjust previous/next navigation + minor manual clean) |
||
Line 4: | Line 4: | ||
|id=111 |
|id=111 |
||
|previous=108 |
|previous=108 |
||
− | |next= |
+ | |next=113 |
|created=2001 |
|created=2001 |
||
|complexity=intermediate |
|complexity=intermediate |
||
Line 13: | Line 13: | ||
|category2= |
|category2= |
||
}} |
}} |
||
− | I have found it undesirable to use :hardcopy directly because it uses the current syntax highlighting to determine how to print the text. For example, I like to print comments in italics, but I don't like italic fonts on the screen. This tip will show you how to set up a colorscheme for printing and use it only when you print. |
+ | I have found it undesirable to use <tt>:hardcopy</tt> directly because it uses the current syntax highlighting to determine how to print the text. For example, I like to print comments in italics, but I don't like italic fonts on the screen. This tip will show you how to set up a colorscheme for printing and use it only when you print. This assumes that you are already using a colorscheme. |
+ | |||
⚫ | |||
+ | <pre> |
||
⚫ | |||
+ | </pre> |
||
⚫ | |||
⚫ | |||
to this: |
to this: |
||
+ | <pre> |
||
− | + | highlight clear Normal |
|
+ | </pre> |
||
Then I set the syntax groups how I wanted them to be printed on the printer: |
Then I set the syntax groups how I wanted them to be printed on the printer: |
||
+ | <pre> |
||
⚫ | |||
− | + | highlight Comment term=italic cterm=italic gui=italic |
|
⚫ | |||
− | etc.... |
||
+ | ...etc... |
||
− | |||
+ | </pre> |
||
⚫ | |||
⚫ | |||
− | |||
− | And, finally, I defined this function in my .vimrc: |
||
⚫ | |||
<pre> |
<pre> |
||
⚫ | |||
function DoMyPrint(args) |
function DoMyPrint(args) |
||
− | + | let colorsave=g:colors_name |
|
− | + | color print |
|
− | + | exec 'hardcopy '.a:args |
|
− | + | exec 'color '.colorsave |
|
endfunction |
endfunction |
||
</pre> |
</pre> |
||
− | After this is complete, you can do: |
+ | After this is complete, you can do (use uppercase 'H'): |
+ | <pre> |
||
− | + | :Hardcopy > /tmp/out.ps |
|
+ | </pre> |
||
+ | |||
or just |
or just |
||
+ | <pre> |
||
− | + | :Hardcopy |
|
− | (Note the capital H) |
||
+ | </pre> |
||
==Comments== |
==Comments== |
||
− | This does, BTW, assume that you are already using a colorscheme. |
||
− | |||
− | ---- |
Revision as of 10:16, 23 April 2011
Duplicate tip
This tip is very similar to the following:
These tips need to be merged – see the merge guidelines.
created 2001 · complexity intermediate · author Aric Blumer · version 6.0
I have found it undesirable to use :hardcopy directly because it uses the current syntax highlighting to determine how to print the text. For example, I like to print comments in italics, but I don't like italic fonts on the screen. This tip will show you how to set up a colorscheme for printing and use it only when you print. This assumes that you are already using a colorscheme.
I copied an existing colorscheme to ~/.vim/colors/print.vim, and changed all the lines like this:
highlight Normal ctermbg=DarkGrey ctermfg=White guifg=White guibg=grey20
to this:
highlight clear Normal
Then I set the syntax groups how I wanted them to be printed on the printer:
highlight Comment term=italic cterm=italic gui=italic highlight Constant term=bold cterm=bold gui=bold ...etc...
I then defined the following command and function in my vimrc:
command! -nargs=* Hardcopy call DoMyPrint('<args>') function DoMyPrint(args) let colorsave=g:colors_name color print exec 'hardcopy '.a:args exec 'color '.colorsave endfunction
After this is complete, you can do (use uppercase 'H'):
:Hardcopy > /tmp/out.ps
or just
:Hardcopy