digitalFAQ.com Forum

digitalFAQ.com Forum (https://www.digitalfaq.com/forum/)
-   Computers (https://www.digitalfaq.com/forum/computers/)
-   -   Remove extra lines (empty lines) from copied/pasted text with Notepad++ (https://www.digitalfaq.com/forum/computers/3579-remove-extra-lines.html)

kpmedia 10-07-2011 05:28 PM

Remove extra lines (empty lines) from copied/pasted text with Notepad++
 
1 Attachment(s)
I often find myself needing to remove extra junk and extra spaces from copy/pasted text. I'm already using a clipboard stripper (PureText) to remove underlying HTML code or Word code, and then using Notepad (or Notepad++) to search and find/replace duplicate spaces and odd characters. But what about extra line breaks?

Notepad++ has a nifty feature called Extended Search Mode under the Search > Replace options.

To remove empty blank lines, simply find \n\r and then replace with nothing.
All completely empty lines will be removed.

Attachment 1929

The only problem I've run into is when a line is not completely empty. For example, if each line has a space on it. In theory, you could search/replace all single spaces with nothing, but that would obviously mess up text.

If you know how to replace lines with spaces, please reply to this post, and share your knowledge!

The official site for Notepad++ is http://notepad-plus-plus.org
The official site for PureText is http://www.stevemiller.net/puretext/
Both are freeware.

kpmedia 10-07-2011 05:32 PM

Also ...

If you want to remove line breaks, and put all text into a single paragraph, you can use the search string \r\n
Notice that the R and N have switched places.

The only caveat here, however, is that spaces may not be added between merged sentences. This is easy enough to fix with two more quick search/replace queries.

1. Find all periods, and replace with period + space --- "." is replaced with ". "

2. For all sentences that previous had a proper space, an extra space has been added. To correct this, simply search/replace two spaces
-- a single space "_" is replaced with two spaces "__"

Easy enough. ;)


All times are GMT -5. The time now is 10:32 AM

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.