Visual Studio Code: Find empty files
Asked Answered
N

2

6

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.

Needham answered 19/7, 2019 at 12:32 Comment(5)
Did you find any solution? I would appreciate it.Nostril
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..)Needham
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.Nostril
yeah - however the topic here is to do that within vsc... there are plenty other waysNeedham
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.Witchy
I
3

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.

Isostasy answered 11/4, 2023 at 17:16 Comment(1)
Bit dated, but i recall vaguely winding up with a similar solution, using negative lookarounds (inspired by @Witchy ´s respond). Therefore (and to close this thread ;) I’ll mark this as appropriate answer. Thank you!Needham
B
6

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

Bradley answered 10/12, 2019 at 23:14 Comment(1)
find . -empty -type f if you want to find only empty files (not folders)Mcneese
I
3

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.

Isostasy answered 11/4, 2023 at 17:16 Comment(1)
Bit dated, but i recall vaguely winding up with a similar solution, using negative lookarounds (inspired by @Witchy ´s respond). Therefore (and to close this thread ;) I’ll mark this as appropriate answer. Thank you!Needham

© 2022 - 2025 — McMap. All rights reserved.