URL:         http://www.math.fu-berlin.de/~guckes/vim/howto/print.html
URL:         https://www.vim8.org/howto/print.html (mirror)
Created:     Tue Aug 25 18:00:00 CEST 1998
Last update: Thu Jan 07 18:00:00 CET 1999

Vim HowTo - Printing Text

DOS: Write the file and use "type" externally to hand over the "file" to "prn":

	:w file
	:!type file > prn
:w filename :!type filename > prn PowerUser method: Use Vim's "append write": :w>>prn
Print a "range" of line (ie "from line M to line N"): Format of command:
	:<range>w !lp
or	:M,Nw !lp
Examples:
	Print from line 10 to line 20 (inclusive):
	:10,20w !lp
	Print from current line to line 100 (inclusive):
	:.,100w !lp
	Print from first line to current line (inclusive):
	:1,.w !lp
	Print from current line to line 100 (inclusive):
	:.,100w !lp
	Print from current line to last line (inclusive):
	:.,$w !lp
	Print all lines (ie from first line to last line) (inclusive):
	:1,$w !lp
	:%w !lp
Printing visual text: Type ':' as the operator and Vim will use the range "'<,'>" to denote the previous visual text; now you can apply the write command:

	:'<,'>w !lp

Printing Colorized Texts

[990107] Vim does not produce extra codes for prining in color. However, you can use the file "2html.vim" to make gvim convert a colorized text into a webpage using the color codes as used by the Netscape browser. Just :source $VIM/syntax/2html.vim to do this. And take a look at the notes with ":help convert-to-HTML"!


Send feedback on this page to
Sven Guckes [email protected]