Notepad++ - How can I replace blank lines [duplica

2019-01-29 21:30发布

This question already has an answer here:

I have a text file with a thousand lines of numbers like so:

402

115

90

...

As you can see there is a blank line in between each number that I want to remove so that I have

402
115
90
...

How can I do this?

6条回答
叼着烟拽天下
2楼-- · 2019-01-29 22:03

By the way, in Notepad++ there's built-in plugin that can handle this: TextFX -> TextFX Edit -> Delete Blank Lines (first press CTRL+A to select all).

查看更多
我想做一个坏孩纸
3楼-- · 2019-01-29 22:04
  1. Press Ctrl+H (Replace)

  2. Select Extended from SearchMode

  3. Put \r\n\r\n in Find What

  4. Put \r\n in ReplaceWith

  5. Click on Replace All

Replace multiple line breaks

查看更多
Ridiculous、
4楼-- · 2019-01-29 22:13

As of NP++ V6.2.3 (nor sure about older versions) simply:

  1. Go menu -> Edit -> Line operations
  2. Choose "Remove Empty Lines" or "Remove Empty Lines (Containing white spaces)" according to your needs.

Hope this helps to achieve goal in simple and yet fast way:)

查看更多
叛逆
5楼-- · 2019-01-29 22:18

This should get your sorted:

  • Highlight from the end of the first line, to the very beginning of the third line.
  • Use the Ctrl + H to bring up the 'Find and Replace' window.
  • The highlighed region will already be plased in the 'Find' textbox.
  • Replace with: \r\n
  • 'Replace All' will then remove all the additional line spaces not required.

Here's how it should look: enter image description here

查看更多
兄弟一词,经得起流年.
6楼-- · 2019-01-29 22:23

This will remove any number of blank lines

CTRL + H to replace

Select Extended search mode

replace all \r\n with (space)

then switch to regular expression and replace all \s+ with \n

查看更多
我欲成王,谁敢阻挡
7楼-- · 2019-01-29 22:25

You can record a macro that removes the first blank line, and positions the cursor correctly for the second line. Then you can repeat executing that macro.

查看更多
登录 后发表回答