The help text is a little vague as to what this command achieves.

                    Print [range] lines (default current line).
                    Note: If you are looking for a way to print your text
                    on paper see |:hardcopy|.  In the GUI you can use the
                    File.Print menu entry.
                    See |ex-flags| for [flags].

I know I've used it by mistake to mean :p[rev] several times in the past, but I've never heard the whirring of a printer. Nor have any strange files appeared, nor have I found the line I am on appear in stdout.

So what then, does typing :print do in vim?


Historically, in the 'ed' editor (which many of the core :commands ultimately originate from), the line would go to stdout.

Of course, since vim is a full screen editor, the output of commands doesn't just go unprocessed to stdout, but rather is displayed at the bottom of the window. (one line goes in the command bar, more than one line [technically more than 'cmdheight'] gets "Press ENTER or type command to continue", more than will fit on the screen gets a -- More -- prompt.)

When you simply type :p you will see (you may not have noticed) the line you are on appear in the command bar.

This command is not particularly useful on its own (it was slightly more useful in ed, when the line you are editing would not otherwise be displayed on the screen), but becomes more useful in conjunction with other addressing modes. For example, :g/re/p (where re is any regular expression) has often been claimed to be the origin of the name of the grep command.


It prints the current line, or the range of lines. The :%p command will print the whole file (for example). "Print" doesn't mean "print on printer" (which the manual that you quote points out too) but probably has more to do with the corresponding p command in e.g. sed and ed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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