如何在VS Code中删除空行

I recently had to work with a file, in VS Code, that had several empty lines I wanted to remove all at once.

最近,我不得不使用VS Code中的文件,其中有几个空行,我想一次将其全部删除。

We’re talking about 700+ empty lines with some text in between, and I didn’t want to do this manually.

我们谈论的是700多个空行,中间有一些文本,我不想手动执行此操作。

I’m a programmer, so I’d rather spend 5 minutes making a task easier rather than spend the same amount of time doing an annoying job.

我是一名程序员,所以我宁愿花5分钟简化任务,也不愿花相同的时间来完成烦人的工作。

I searched a bit and found this simple way to do so: replace \n\n with \n.

我搜索了一下,发现这样做的简单方法:用\n\n替换\n\n \n

Remove empty lines in VS Code

I ran “replace all” inside the file, and half of the lines were removed. So I ran it again, and again and again, until I got to 1 empty line.

我在文件中运行了“全部替换”,并且删除了一半的行。 因此,我一次又一次地运行它,直到到达1个空行。

Update: \n\n+ will replace all lines at once without having to repeat the operation

更新: \n\n+将一次替换所有行,而无需重复操作

翻译自: https://flaviocopes.com/vscode-remove-empty-lines/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值