• Login
Community
  • Login

add line breaks without breaking word

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
line separatorhelphelpmacrosparagraph
5 Posts 3 Posters 428 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R
    Rose Greene
    last edited by May 18, 2021, 10:56 PM

    i was wondering if there was a way i could add a line break every x amount of characters without breaking words? something kind of like this:

    before

    hello! this is just a fake line of text for this example. have a good day!
    

    after

    hello! this is just a 
    fake line of text for 
    this example. have a 
    good day!
    

    kind of like this website.

    i wanted to record a macro of it so i wouldn’t have to constantly go to the website mentioned.

    thank you!

    P 1 Reply Last reply May 18, 2021, 11:20 PM Reply Quote 0
    • P
      PeterJones @Rose Greene
      last edited by May 18, 2021, 11:20 PM

      @Rose-Greene ,

      It’s not a macro, because macro won’t change a setting… but if you go to Preferences > Margins/Border/Edge, and change the Vertical Edge Settings to 23 (for your example), then hit Ctrl+I (aka Edit > Line Operations > Split), it will split the line at the margin. So you can pick the appropriate Vertical Edge column and then use the Split command to do what you want.

      There are ways to get regular expression search/replace to do something similar, but this is much simpler, IMO.

      R 1 Reply Last reply May 18, 2021, 11:27 PM Reply Quote 4
      • R
        Rose Greene @PeterJones
        last edited by May 18, 2021, 11:27 PM

        @PeterJones This works great thanks!

        1 Reply Last reply Reply Quote 1
        • A
          Abed99
          last edited by May 20, 2021, 4:06 PM

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • A
            Abed99
            last edited by Abed99 May 20, 2021, 4:47 PM May 20, 2021, 4:45 PM

            PeterJones mention a good way and here is another way using regex:

            search for :(\w+\.?!?\s){2}
            replace with : $&\r\n
            search mode : regular expression
            

            change 2 to the X amount of characters you want
            3.png

            1 Reply Last reply Reply Quote 0
            3 out of 5
            • First post
              3/5
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors