VI / Vim Print Line Numbers on Hardcopies / Printer

last updated in Categories , ,

How do I print line numbers on the printer for my c / java / c++ code written using vi or vim text editor under Linux / UNIX like operating system?

To print line number on screen and hardcopies such as printer type the following two commands while vim / vi text editor is open:

set number
set printoptions=number:y

Make sure you add above two commands to your ~/.vimrc file; so that settings get loaded everytime you start the vim text editor.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 7 comments/add one below):

7 comment

    Have a question? Post it on our forum!