Sublime Text: Invert Selection from Find Search Matches

One thing that’s nice about the Linux program, grep, is that it only shows you lines that match your search condition and removes all non-matching lines. You can accomplish the same thing and more with the Sublime Text editor. In addition to removing non-matching lines, it can remove all non-matching text leaving you with only the matches you want. Just do the following

  1. Enter your search condition
  2. Click the Find All button
  3. Click Selection > Invert Selection
  4. Delete the inverted selection
  5. Hit Enter to put each match on a separate line (notice the multiple cursors flashing)

UPDATE: Actually, after you click the Find All button, you can just copy all matches (CTRL+C) and paste them into a new file to accomplish the same thing as steps 3, 4, 5.

invert-selection1

invert-selection2

invert-selection3

invert-selection4