Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On Linux, I sometimes see a list of all the lines which match a term with this handy command:

:! grep -n "term" %

However, I am now stuck on a Windows XP SP3 machine which lacks grep! Is there a way to get this list from within VIM itself, or using some other Windows tool via :!?


share|improve this question
up vote 6 down vote accepted

Use :g.



(Trivia: grep was named after the same g/re/p command in the ed editor, where re stands for "regular expression". The p suffix is optional, and is an abbrev for :print.)

To also display line numbers, either add :nu:


or just enable 'number' with :set number.

As an alternative to grep, Windows comes with tools find and findstr that have the same basic functions.

:! find "term" %

:! findstr term %
share|improve this answer
By all means, stick with :g. find and findstr seem to be specifically engineered to trip up the grep-familiar. – bonsaiviking Apr 16 '12 at 16:13
Terrific, thank you! I knew that there had to be a VIM-internal command! – dotancohen Apr 16 '12 at 18:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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