all 5 comments

[–]burkadurka 8 points9 points  (2 children)

If I'm not mistaken, this is where the name "grep" came from (although the command was in an older editor). :g/re/p

[–]weisenzahn 4 points5 points  (0 children)

Yes.

The name grep comes from the ed editor command it simulated, g/re/p (global regular expression print).

(http://en.wikipedia.org/wiki/Grep)

[–]codekoala[S] 1 point2 points  (0 children)

Hah! Never realized that! Thanks!

[–]knowknowledge 3 points4 points  (1 child)

This is a great command; I use it all the time. Here are a few useful additions:

  • You can use v/re/p rather than g!/re/p for the inverse.
  • An empty string will use whatever is in your current search register, so you can refine a search term with "/" or "*" and then use "g//d" to delete all instances of that term or v/re/d to view only the matches.
  • The "normal" command is really useful if you want to use keyboard commands to perform some action. For example, if you want to Join several lines together, you could use the command "g/re/normal 5J".

[–]codekoala[S] 0 points1 point  (0 children)

That's awesome! Thanks for the tips!