用VSCODE删除文件中的空行,但仅在文件的开始和结尾处
这是我的文字:
<---- empty line to delete
<---- empty line to delete
Lorem ipsum
Lorem ipsum
<---- empty line to keep
Lorem ipsum
<---- empty line to delete
这是我想使用vscode
REGEX或您可能知道的任何扩展名。
Lorem ipsum
Lorem ipsum
Lorem ipsum
有什么想法吗?谢谢!
编辑:我可能需要确切地说,我想在12000多个文件上实现此目标。因此,无法想象手动做这个。而且我还没有找到任何扩展名,也没有关于这个主题的答案。
Here is my text :
<---- empty line to delete
<---- empty line to delete
Lorem ipsum
Lorem ipsum
<---- empty line to keep
Lorem ipsum
<---- empty line to delete
Here's what I would like to have using VSCode
regex, or any extension you might know about.
Lorem ipsum
Lorem ipsum
Lorem ipsum
Any idea ? Thanks!
EDIT: I might need to precise that I want to achieve this on more than 12000 files. So can't imagine doing this manually.. And I haven't found any extensions yet, neither answers about this subject.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于末尾的空行,您可以使用
\ n+$(?![\ r \ n])
在VSCODE中删除它们。对于第一条空行应该工作(?)
(?&lt;!(。| \ n))\ n+
。Regex的其他口味具有(尽管它们似乎在VSCODE中不起作用)具有
\ A
或\
和\ z
\'
用于文件的开始和结尾。For empty lines at the end, you can remove them with
\n+$(?![\r\n])
in VSCode.For the first empty lines should work (?)
(?<!(.|\n))\n+
.Other flavours of regex have (although they don't seem to work in VSCode) have
\A
or\`
and\Z
\'
for start and end of file.