Vim Tips Wiki
We recommend that you log in before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your Watchlist. Creating an account is quick and free.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 12: Line 12:
 
|category2=
 
|category2=
 
}}
 
}}
To get this to work you have to know how many lines per page :hardcopy is normally making. Open empty document and in Normal mode "100o". Then make ":%s/^/\=line('.')". Now ":hardcopy > nu.ps". Open nu.ps in PostScript viewer. You will see how many lines per page Vim is printing.
+
To get this to work you have to know how many lines per page :hardcopy is normally making. Open empty document and in Normal mode "100o". Then make ":%s/^/\=line('.')". Now ":hardcopy > nu.ps". Open nu.ps in PostScript viewer. You will see how many lines per page Vim is printing.
   
 
In my case this is 73. Now set the 'printheader' option:
 
In my case this is 73. Now set the 'printheader' option:
   
:set printheader=%<%f%h%m%=Page\ %N\ of\ %{line('$')/73+1}
+
:set printheader=%&lt;%f%h%m%=Page\ %N\ of\ %{line('$')/73+1}
   
 
<pre>
 
<pre>
Line 40: Line 40:
 
endif
 
endif
 
endfunction
 
endfunction
set printheader =%<%f%h%m%=Page\ %N\ of\ %{PH_Multiple()}
+
set printheader =%&lt;%f%h%m%=Page\ %N\ of\ %{PH_Multiple()}
 
</pre>
 
</pre>
   
Line 46: Line 46:
 
Some nice additions from comp.editors:
 
Some nice additions from comp.editors:
   
:set printheader=%<%f%h%m%=Page\ %N\ of\ %{line('$')/73+(line('$')%73!=0)}
+
:set printheader=%&lt;%f%h%m%=Page\ %N\ of\ %{line('$')/73+(line('$')%73!=0)}
   
:set printheader=%<%f%h%m%=Page\ %N\ of\ %{(line('$')-1)/73+1}
+
:set printheader=%&lt;%f%h%m%=Page\ %N\ of\ %{(line('$')-1)/73+1}
   
 
----
 
----
Clever; however there are multiple settings (see e.g. 'printfont' & 'printoptions') which can change the number of lines per page. Also, if long lines wrap when printed (the default), then the number of lines in the buffer may not match the number of lines printed.
+
Clever; however there are multiple settings (see e.g. 'printfont' &amp; 'printoptions') which can change the number of lines per page. Also, if long lines wrap when printed (the default), then the number of lines in the buffer may not match the number of lines printed.
   
 
----
 
----
 
A simpler way to do the page count arithmetic:
 
A simpler way to do the page count arithmetic:
   
:set printheader=%<%f%h%m=Page\ %N\ of %{(line('$')+72)/73}
+
:set printheader=%&lt;%f%h%m=Page\ %N\ of %{(line('$')+72)/73}
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel Editing help (opens in new window)