5

Is there a way to find all empty files (with vscode) in a project? I try to open all my .scss files, and already installed 'search - open all results', however even with regEx I wasn't able to find them all because some of them are empty.

Also I just discoverd, that this extension only opens the first 10 matches (regardless if in the same file or not) - so a more handy solution would be preferable.

matt
  • 105
  • 10
  • Did you find any solution? I would appreciate it. – Mustafa Mohammadi Sep 18 '19 at 03:44
  • not so far - worked around then. sry ..however giving it another thought.. what about an empty regex? i mean.. it is line/stream based, but wouldn't do sth. like this the trick: `(?!\n|.|\r|\Z)` (..not tested..) – matt Sep 19 '19 at 10:21
  • I did something easy. Went to the explorer where project is located, searched in window search like .css size:empty. In my case, I wanted to find all css files which are empty. – Mustafa Mohammadi Sep 19 '19 at 16:15
  • yeah - however the topic here is to do that _within_ vsc... there are plenty other ways – matt Sep 24 '19 at 12:39
  • 2
    This regex seems to work in vscode: `(?<!\s)(^$)(?!\n)` if by empty you mean one line with nothing on it. And not even one `newline`. – Mark Dec 12 '19 at 04:55

2 Answers2

5

You could open a terminal in vscode and run find . -empty

tcigrand
  • 2,357
  • 2
  • 14
  • 24
2

This regex would allow you to find empty files ^$(?<!\n)(?!\n). It's basically saying, find all empty lines that are not preceded by or followed by a new line.

William Neely
  • 1,923
  • 1
  • 20
  • 23
  • 1
    Bit dated, but i recall vaguely winding up with a similar solution, using negative lookarounds (inspired by @Mark ´s respond). Therefore (and to close this thread ;) I’ll mark this as appropriate answer. Thank you! – matt Jun 20 '23 at 13:03