Results 1 to 9 of 9

Thread: Notepad++ Line Break Question

  1. #1
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    190
    Thanks
    70
    Thanked 3 Times in 3 Posts

    Default Notepad++ Line Break Question

    Hey Guys,

    Miss me?

    Here's the question: Can notepad++ run through a file and convert all occurrences of double line break into single line break? If so, how? If not, are y'all aware of other software that can?

    Best,

    A.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,373
    Thanks
    77
    Thanked 3,421 Times in 3,382 Posts
    Blog Entries
    12

    Default

    What you do is from the search menu, choose replace. Then in the dialog box check only the extended option. In the search field use:

    \r\n\r\n

    in the replace field use:

    \r\n

    then click replace all.

    That's for carriage return (\r) linefeed (\n) (in windows). If you have a MAC I think it's \r\r replace with \r, but it might be \n\n replace with \n. Unix may be one of those as well. You can tell by first doing a search to see if there are any of those available in the file. Even if you are in Windows, if the file originated on another OS (other than windows) you might need to use their method. And visa versa, say if you are on a MAC editing a Windows file.

    If there are triple or quadruple, etc. line breaks that you also want to eliminate, you will have to run it two or more times.
    Last edited by jscheuer1; 08-07-2017 at 05:17 PM. Reason: correction
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    190
    Thanks
    70
    Thanked 3 Times in 3 Posts

    Default

    Suggestion makes perfect sense. Unfortunately, it does not work. (I tried to paste a screen image, but was unable to. I can send the image to you as a pdf file or as an xlsx file if you tell me where to send it.)

    A.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,373
    Thanks
    77
    Thanked 3,421 Times in 3,382 Posts
    Blog Entries
    12

    Default

    Well it worked here, so unless you didn't have the extended option checked, or didn't use the search terms and the replace terms I supplied, I don't know what to say. What kind of file are you trying to edit? You could always put a screen shot up on one of your sites and post a link to it here.

    Oh, it just occurred to me, maybe you have spaces or tabs on the empty lines. Then you would need a regex, and I haven't figured out how those work in Notepad++ yet. I'll have another look now.

    OK, just looked into regex on my Notepad++, it doesn't appear to span lines no matter what settings one uses and doesn't recognize ^$ as representing an empty line. So it's unlikely it can be used for this.
    Last edited by jscheuer1; 08-08-2017 at 02:21 PM. Reason: add info
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,373
    Thanks
    77
    Thanked 3,421 Times in 3,382 Posts
    Blog Entries
    12

    Default

    OK, this should work, assuming your Notepad++ is like mine and that there's nothing else going on that's odd. First backup the file just in case. Next do a regular expression wraparound replace on:

    ^\s+$

    That's a beginning of a line followed by one or more white space characters followed by the end of the line. Replace them with nothing (blank in the replace field).

    Then (keeping wraparound on) switch to the extended option and replace: \r\n\r\n with \r\n or whatever (as noted previously if the file is in MAC or UNIX format it might be \r\r with \r or \n\n with \n).
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    190
    Thanks
    70
    Thanked 3 Times in 3 Posts

    Default

    John,

    Thank you for the time you are spending on this.

    Here are three links to screen shots you suggested:

    https://www.njexpungements.com/screenshot1.xlsx
    https://www.njexpungements.com/screenshot2.xlsx
    https://www.njexpungements.com/screenshot3.xlsx

    A.

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,373
    Thanks
    77
    Thanked 3,421 Times in 3,382 Posts
    Blog Entries
    12

    Default

    OK, the 3rd image is right but I think you must have misunderstood with the other two. Or I explained it poorly. And that part needs to be done correctly first if there is any white space on the blank lines (trailing tabs, spaces, etc.).

    When doing the initial wraparound regular expression search, leave the replace field empty. The settings in image 1 and image 2 are the same as far as I can see, and they're both wrong. They should be search on:

    ^\s+$

    and replace with nothing.

    Oh, and when you do the extended (like in image 3) leave wraparound on. Other than that, image 3 looks right.


    Also, the first two images show files that are already single spaced, at least the parts of them that are visible.
    Last edited by jscheuer1; 08-10-2017 at 05:46 PM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. The Following User Says Thank You to jscheuer1 For This Useful Post:

    marain (08-10-2017)

  9. #8
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    190
    Thanks
    70
    Thanked 3 Times in 3 Posts

    Default

    Wow! It worked, finding and replacing 1,832 occurrences. See https://www.njexpungements.com/screenshot1.xlsx. Thank you.

    Now the treated file doesn't load properly, but that's a different problem!

    A.

  10. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,373
    Thanks
    77
    Thanked 3,421 Times in 3,382 Posts
    Blog Entries
    12

    Default

    Was it working before? Need to know that (if it was, hope you kept that suggested backup). In either case, why not post a detailed question about it in a new thread?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Resolved To Code a Line Break
    By marain in forum PHP
    Replies: 12
    Last Post: 12-21-2014, 04:27 PM
  2. GD Image - Line Break?
    By Vernier in forum PHP
    Replies: 7
    Last Post: 08-16-2012, 02:53 PM
  3. CSS Extra Line Break
    By Johnnymushio in forum CSS
    Replies: 2
    Last Post: 04-07-2011, 06:15 PM
  4. line break before pre tag, get rid of
    By chopficaro in forum CSS
    Replies: 4
    Last Post: 03-16-2010, 01:31 AM
  5. IE adds line break?
    By thenajsays in forum CSS
    Replies: 4
    Last Post: 06-10-2008, 04:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •