≡ Menu

VI / Vim Print Line Numbers on Hardcopies / Printer

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?

Tutorial details
DifficultyEasy (rss)
Root privilegesNo
Estimated completion timeN/A
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.

Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?

{ 6 comments… add one }

  • Giorgis May 31, 2008, 11:38 am

    Great tip, thanks guys (and google)

  • R March 4, 2009, 12:03 am


  • venkatakumar November 12, 2009, 1:45 pm

    What is great tip , it working good.

  • venkatakumar November 12, 2009, 1:45 pm

    what a great tip, it’s working…

  • waleking May 27, 2012, 6:19 am

    Thanks for your tip, it works very well!

  • Philippe Petrinko April 15, 2013, 1:28 pm

    Good to remember, thanks Vivek.
    — Philippe

Leave a Comment