Removing empty lines in Notepad++

前端 未结 22 1759
时光取名叫无心
时光取名叫无心 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:49

    There is now a built-in way to do this as of version 6.5.2

    Edit -> Line Operations -> Remove Empty Lines or Remove Empty Lines (Containing Blank characters)

    0 讨论(0)
  • 2020-11-28 00:49
    1. Press ctrl + h (Shortcut for replace).
    2. In the Find what zone, type ^\R ( for exact empty lines) or ^\h*\R ( for empty lines with blanks, only).
    3. Leave the Replace with zone empty.
    4. Check the Wrap around option.
    5. Select the Regular expression search mode.
    6. Click on the Replace All button.

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

    This obviously does not work if the blank lines contain tabs or blanks. Many web pages (e.g. http://www.guardian.co.uk/) contain these white lines, as a result of a faulty HTML editor.

    Remove white space using regular expression as follows:

    change pattern: [\t ]+$ into nothing.

    where [\t ] matches either tab or space. '+' matches one or more occurrences, and '$' marks the end of line.

    Then use notepad++/textFX to remove single or extra empty lines. Be sure that these blank lines are not significant in the given context.

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

    /n/r assumes a specific type of line break. To target any blank line you could also use:

    ^$
    

    This says - any line that begins and then ends with nothing between. This is more of a catch-all. Replace with the same empty string.

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

    In notepad++ press CTRL+H , in search mode click on the "Extended (\n, \r, \t ...)" radio button then type in the "Find what" box: \r\n (short for CR LF) and leave the "Replace with" box empty..

    Finally hit replace all

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

    Ctrl+H.

    find - \r\r replace with - \r.

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