I was looking for a way to show a bit of context around my searches when doing


When I stumbled across this page Search-a-pattern-and-provide-a-context-few-lines-above-and-below where someone mentions the mysterious (to me) search flag 'z'. As in


My initial research suggests it some sort of 'total number of lines returned per result' but setting it to z#.2 only shows one line per search result. So I am confused and I'm having trouble finding the docs under :help pattern.

So here are my questions:

  • What does the z flag do?
  • How does #.3 modify it?
  • Where in the docs can I find this information?

1 Answer 1


Let's dissect this. :help :g tells you that the last thing is a command, not a flag (like those of :substitute):


Let's try :help :z; voilà:

:{range}z[+-^.=]{count} Display several lines of text surrounding the line
                            specified with {range}, or around the current line
                            if there is no {range}.
                            Like ":z", but number the lines.

So, you'll get a numbered (#) printing of 3 lines around (.) the current line (that matches cat).

  • 1
    The z#.2 doesn't work because it addresses 1/2 above / below, and that seems to be rounded down to 1. Feb 11, 2014 at 16:43
  • Bah! Good call I definitely spaced on looking through the docs there. I was doing :help z (no colon).
    – jmathew
    Feb 11, 2014 at 16:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .