Visual Studio Code - 从代码中删除空行 [英] Visual Studio Code - Remove blank lines from code
问题描述
我使用 Visual Studio Code 作为首选的文本编辑器,但遇到了格式方面的问题.我已经从一个文件中复制了代码并粘贴到另一个文件中,但是当我粘贴代码时,VSC 在每行代码之间放置了一个空行.
这是一个相当大的文件,所以我希望有一种方法可以一次识别所有空行并删除它们?
这就是我希望代码的样子:
<h1></h1><p></p>
然而,在粘贴时它现在看起来像这样:
<h1></h1><p></p>
我在网上看过,但找不到任何直接的答案:(
按照步骤操作
- 按 Ctrl+H(快速替换).
- 点击使用正则表达式".
- 在查找中指定^$\n"
- 点击全部替换".所有空行都将被删除.
I use Visual Studio Code as my preferred text editor and I have ran into a problem with regards to the formatting. I have copied code from one file and pasted into another, however when I have pasted the code VSC has placed a blank line between every line with code.
It is quite a big file so I am hoping there is a way to identify all the blank lines at once and remove them?
This is how I want the code to look:
<div>
<h1></h1>
<p></p>
</div>
however, on paste it now looks like this:
<div>
<h1></h1>
<p></p>
</div>
I have looked online but have been unable to find any direct answer to this :(
Follow the steps
- Press Ctrl+H (quick replace).
- Click "Use Regular Expressions".
- In Find specify "^$\n"
- Click "Replace All". All Blank lines will be deleted.
这篇关于Visual Studio Code - 从代码中删除空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!