Sublime Text 2:如何删除空白/空行 [英] Sublime Text 2: How to delete blank/empty lines

查看:26
本文介绍了Sublime Text 2:如何删除空白/空行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个包含以下九行的文本文件:

Let's say I had a text file with the following nine lines:

foo

bar

baz

qux

quux

如何使用 Sublime Text 2 删除所有四行空白/空行,只留下五行?

How can I use Sublime Text 2 to remove all four of the blank/empty lines, leaving only five lines?

推荐答案

选择文本

按:

  • Ctrl + H 在 PC 上,或
  • Command + Alt + F 在 Mac 或
  • 单击查找"->替换".
  • Ctrl + H on PC, or
  • Command + Alt + F on Mac or
  • Click Find->Replace.

通过按以下键确保您选择了正则表达式":

Make sure you have selected 'regular expression' by pressing:

  • Alt + R 在 PC 或
  • Command + Alt + R 在 Mac 或
  • 在查找"框中单击 .*.
  • Alt + R on PC or
  • Command + Alt + R on Mac or
  • Click .* in the Find box.

求什么:^\n^(\r|\n\r?)

替换为:(无,留空).

Replace With: (nothing, leave in blank).

这篇关于Sublime Text 2:如何删除空白/空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆