Community
    • Login

    add line breaks without breaking word

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    line separatorhelphelpmacrosparagraph
    5 Posts 3 Posters 876 Views 2 Watching
    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.
    • Rose GreeneR Offline
      Rose Greene
      last edited by

      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!

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP Offline
        PeterJones @Rose Greene
        last edited by

        @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.

        Rose GreeneR 1 Reply Last reply Reply Quote 4
        • Rose GreeneR Offline
          Rose Greene @PeterJones
          last edited by

          @PeterJones This works great thanks!

          1 Reply Last reply Reply Quote 1
          • Abed99A Offline
            Abed99
            last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • Abed99A Offline
              Abed99
              last edited by Abed99

              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

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors