15

How do I list the lines that contains the matches from the "find" command ? ie., I would like to list all the matching lines in a separate window. Currently one can only goto next / previous 'find'.

user85917
  • 925
  • 3
  • 12
  • 21

3 Answers3

25

Try 'Find in Files' (Cmd+Shift+F on a Mac, presumably Ctrl+Shift+F on a PC).

Search results will display in a new tab, and you can double-click any result to jump to that line in the matching file.

  • To search only open files, put <open files> in the Where field.
  • To show only the lines that matched without surrounding lines for context, toggle the 'Show Context' option (to the left of the 'Find All' panel).
Sara
  • 8,222
  • 1
  • 37
  • 52
  • 1
    That is what I was looking for, thanks. But Sublime also copies some lines to the Find Results buffer that does not match my search along with the lines that does, I think for context. Is there any settings that give me only the lines that match and none of the others lines? Thanks in advance. – Ither Jan 20 '13 at 04:57
  • 4
    @Ither yes, the 'Show Context' button on the left of the Find All panel (the icon is 3 horizontal lines) will toggle that setting. – Sara Jan 21 '13 at 17:08
  • works flawlessly – Gaurav May 31 '22 at 16:47
18

1.Here is a reference: How can I filter a file for lines containing a string in Sublime Text 2?

  • Hit Ctrl+F(⌘+F) to "Find All" occurences;
  • Hit Ctrl+L to Expand All Selection to Line.
  • Then you can Ctrl+C(⌘+C) or Ctrl+Shift+K(⌃+⇧+K) to copy/delete the lines.

2.There's now a plugin for filtering lines: https://github.com/davidpeckham/FilterLines It allows filtering and code folding based on strings or regular expressions. filterlines plugin:Edit->Line->Filter

Community
  • 1
  • 1
fan2
  • 181
  • 2
  • 4
8

I think the simplest way is just to search for the line like this -> ".*find_this_string.*" and make sure that regular expression is ticked. Then you can click "find all" (alt+enter) and just copy and paste all results to a new window.

MathiasE
  • 467
  • 3
  • 10