Just started using :hardcopy > x.ps to generate input to ps2pdf.

Result is satisfactory but I would like to change the printoptions to non-default values for header, margins and page size, e.g.

set printoptions "left:2pc,right:2pc,top:2pc,bottom:2pc,header:0,paper:A5"

which command is accepted without comment by Vim, but produces no change to printoptions for it is still at its default setting


help for printoptions says it is "{only available when compiled with +printer feature}" which I assume is true, or it would not have any printoptions setting at all.

What am I missing?

  • Don't assume, just run :echo has('printer'). If it says 1, the +printer feature is enabled, 0 otherwise. Or take a look in :version. (just realized Vivian has this covered in his answer, ah well...).
    – Friedrich
    Commented May 25 at 22:09
  • Do you have still something open in your question? How can we help you further? Otherwise maybe could you accept one of the solution using the v button next to the arrow voting buttons. It allow the question to rest :-) Commented May 27 at 10:44
  • 1
    I accepted your answer and upvoted it at my previous visit. Would have thanked you then but was specifically discouraged from doing so, so I'll do that now, and also have ticked it
    – user985675
    Commented Jun 3 at 23:51
  • Thanks for the feedback :-) Commented Jun 4 at 3:57

3 Answers 3


I would do:

set printoptions=left:2pc,right:2pc,top:2pc,bottom:2pc,header:0,paper:A5

The set command needs:

  • an equal sign (=) and
  • no space ( ) in the argument.

Or the variable alternatives:

let &printoptions = "left:2pc,right:2pc,top:2pc,bottom:2pc,header:0,paper:A5"

For complex values that includes special characters (like , |, \) this second form maybe more readable.

Remark: To verify that your version of Vim has the +printer feature you can use the :version command.


The other answers do a great job of explaining how to accomplish your goal. I'll play the unpopular part and explain your error.

Let's split your line into two parts and take a look at them individually:

set printoptions "left:2pc,right:2pc,top:2pc,bottom:2pc,header:0,paper:A5"
|<-- part 1 -->| |<----                 part 2                      ---->|

Part 1 is a complete Ex command: :set printoptions. Quoting from :help :set:

:se[t] {option}     Toggle option: set, switch it on.
                    Number option: show value.
                    String option: show value.

As 'printoptions' is a string option, this will show its current value in the command line. Nothing more.

Part 2 is a comment, because comments in Vimscript start with a quote. They can follow :set commands.

In fact, :help :comment features an example just like yours:

:set ai     "set 'autoindent' option

The solution - as already pointed out by Vivian and MDeBusk - is to use an equal sign and not to quote your string, see :help :set=:

set printoptions=left:2pc,right:2pc,top:2pc,bottom:2pc,header:0,paper:A5
  • 1
    Not unpopular with everyone.
    – romainl
    Commented May 26 at 11:34
  • 1
    Don't tell me you like to point out people's mistakes? I'd never have suspected.
    – Friedrich
    Commented May 26 at 16:32
  • Perhaps I owe you an apology, my failure to press the tick symbol led you to believe I hadn't understood the answers provided and to provide your detailed explanation of my error. Just the presence of the = sign in the solutions was sufficient. My bad.
    – user985675
    Commented Jun 3 at 23:59
  • @user985675 "Perhaps I owe you an apology" - err... no. I wrote my answer because I felt there should be a more thorough explanation of the error. "Teach a man to fish" and all that. This is just how this site works and there's no need to apologize.
    – Friedrich
    Commented Jun 4 at 5:27

Try this and see what happens:

set printoptions=left:2pc,right:2pc,top:2pc,bottom:2pc,header:0,paper:A5

I just tried it and it worked here. Vim 9.1, patches through 408, compiled by me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.