1.Ctrl+H 打开替换窗口( 注意选择合适的查找范围 )
VS2010:
![](https://file.jishuzhan.net/article/1709162904504242177/2e0aafcdb7d0b994efe93893a46d1dd3.webp)
VS2017、VS2022:
![](https://file.jishuzhan.net/article/1709162904504242177/8f45f927815e14f35bde721abaffa05e.webp)
2. 复制下面正则表达式到上面的选择窗口:
VS2010: ^(\s*)$\n\n
![](https://file.jishuzhan.net/article/1709162904504242177/05c8d6eb3d922720c2cd262c79e0b650.webp)
VS2017: ^(\s*)$\n\n
![](https://file.jishuzhan.net/article/1709162904504242177/6d8976bd2778f0394972a747c65c31cc.webp)
VS2022:^(\s*)$\n
![](https://file.jishuzhan.net/article/1709162904504242177/83e2a47be456b56748db36e4db0c1854.webp)
3. 下面的替换窗口皆写入 \n
VS2010: \n
![](https://file.jishuzhan.net/article/1709162904504242177/7b3032b8ec58ffe37ab9f52290d4a11b.webp)
VS2017: \n
![](https://file.jishuzhan.net/article/1709162904504242177/48a126a5e9c0b15b017bd5a092b99d0d.webp)
VS2022: \n
![](https://file.jishuzhan.net/article/1709162904504242177/9a2d1bacecc50da1672a073f3b5cb5d0.webp)
4. 点选"正则表达式"
VS2010:
![](https://file.jishuzhan.net/article/1709162904504242177/c4aba4a35792a5977c9c7f83bed90fbf.webp)
VS2017:
![](https://file.jishuzhan.net/article/1709162904504242177/a5397ecc1f28ddf9675b32412617c59e.webp)
VS2022:
![](https://file.jishuzhan.net/article/1709162904504242177/502e9a57ce7113a6cfb4b24cd5971201.webp)
5. 点击全部替换
VS2010:
![](https://file.jishuzhan.net/article/1709162904504242177/695a84536f123e809cfbf751e0ada672.webp)
VS2017、VS2022:
![](https://file.jishuzhan.net/article/1709162904504242177/138eb5b4ffaa0cc52ca78e57a5207c96.webp)
补充正则表达式中部分符号含义
\s代表任意的空字符
\n代表屁股的换行符,如果无法匹配,请用"\n\r"