Removing empty lines in Notepad++

前端 未结 22 1758
时光取名叫无心
时光取名叫无心 2020-11-28 00:04

How can I replace empty lines in Notepad++? I tried a find and replace with the empty lines in the find, and nothing in the replace, but it did not work; it probably needs r

相关标签:
22条回答
  • 2020-11-28 00:38

    A few of the above expressions and extended expressions did not work for me, but the regular expression "$\n$" did.

    0 讨论(0)
  • 2020-11-28 00:39

    I did not see the combined one as answer, so search for ^\s+$ and replace by {nothing}

    ^\s+$ means
      ^ start of line
      \s+ Matches minimum one whitespace character (spaces, tabs, line breaks)
      $ until end of line
    
    0 讨论(0)
  • 2020-11-28 00:39

    this work for me:

    SEARCH:^\r  
    REPLACE:            (empty)
    
    0 讨论(0)
  • 2020-11-28 00:40

    Well I'm not sure about the regex or your situation..

    How about CTRL+A, Select the TextFX menu -> TextFX Edit -> Delete Blank Lines and viola all blank line gone.

    A side note - if the line is blank i.e. does not contain spaces, this will work

    0 讨论(0)
  • 2020-11-28 00:41

    CTRL+A, Select the TextFX menu -> TextFX Edit -> Delete Blank Lines as suggested above works.

    But if lines contains some space, then move the cursor to that line and do a CTRL + H. The "Find what:" sec will show the blank space and in the "Replace with" section, leave it blank. Now all the spaces are removed and now try CTRL+A, Select the TextFX menu -> TextFX Edit -> Delete Blank Lines

    0 讨论(0)
  • 2020-11-28 00:41

    An easy alternative for removing white space from empty lines:

    1. TextFX>TextFX Edit> Trim Trailing Spaces

    This will remove all trailing spaces, including trailing spaces in blank lines. Make sure, no trailing spaces are significant.

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