VI / Vim Print Line Numbers on Hardcopies / Printer

VI / Vim Print Line Numbers on Hardcopies / Printer

To print line numbers on hardcopies or printer output when using vi or vim, you can use the :set number command to enable line numbering, and then use the :hardcopy command to send the file to the printer.

For example, to enable line numbering and print the current file, you can use the following commands:

ref‮al:ot re‬utturi.com
:set number
:hardcopy

By default, the :hardcopy command sends the file to the printer specified in the PRINTER environment variable. If this variable is not set, you can use the :hardcopy > file.ps command to redirect the output to a file in PostScript format, which you can then print using a PostScript printer or a program that can read PostScript files.

You can also use the :set printoptions command to specify additional options for printing, such as the page width and margins. For example, to set the page width to 80 characters and the left and right margins to 10 characters, you can use the following command:

:set printoptions=number:y,paper:a4,width:80,left:10,right:10
Created Time:2017-10-30 14:27:31  Author:lautturi