Sublime Text 2: How to delete blank/empty lines

前端 未结 19 1536
北恋
北恋 2020-12-12 09:02

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

foo

bar

baz

qux

quux

How can I use Sublime Text 2 to remove all four of the

相关标签:
19条回答
  • 2020-12-12 09:28

    You are looking for this:

    ^\n|^\s+$
    

    it will not delete the line, if there is content with white space or tabs in front>

    e.g.:

    these will not be deleted: ...space... abc

    ...tab... abc

    this will:

    ...space... ...nothing else...

    ...tab... ...nothing else...

    0 讨论(0)
  • 2020-12-12 09:28

    There is a wonderful package (for Sublime 2 & 3) called 'Trimmer' which deletes empty lines. It also does many other useful things.

    Refer this: https://packagecontrol.io/packages/Trimmer

    0 讨论(0)
  • 2020-12-12 09:29

    Using multiple selections: select one pair of line breaks, then use Quick Find All (Alt+F3), or Quick Add Next (Ctrl+D) repeatedly, to select them all; then hit Enter to replace them with single line breaks.

    0 讨论(0)
  • 2020-12-12 09:29

    Another way, you can use the command line cc.dbl of ConyEdit (a plugin) to delete blank lines or empty lines.

    0 讨论(0)
  • 2020-12-12 09:31

    For those who are curious of sublime text editor, the unofficial-documentation may be interesting!

    0 讨论(0)
  • 2020-12-12 09:31

    To find extra spaces and blank lines press Ctrl+Shift+F Select Regular Expressions Find

    [\n\r]{2,}

    and then replace with

    \n

    to remove all kind of spaces in sublime and dreamviewr

    0 讨论(0)
提交回复
热议问题