Community
    • Login

    How do I get the file to wrap the line at 78 characters?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    wrap
    5 Posts 4 Posters 25.8k 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.
    • Carl YorkeC
      Carl Yorke
      last edited by

      I need my UTF-8 files to not exceed 78 characters . How do I do that?
      Thanks.

      1 Reply Last reply Reply Quote 0
      • Carl YorkeC
        Carl Yorke
        last edited by

        I guess it can’t be done.

        1 Reply Last reply Reply Quote 0
        • tomas-chrastinaT
          tomas-chrastina
          last edited by tomas-chrastina

          Hi Carl,

          it can. Steps:

          1. Backup your file/data!
          2. Install plugin TextFX Characters. It will add menu item TextFX.
          3. Write down number representing length you would like to wrap text to. So in you case:
          78
          
          1. Select and copy this number to clipboard.
          2. Select text you’d like to wrap.
          3. Menu: TextFX -> TextFX Edit -> ReWrap Text to (Clipboard or 72) width
          4. Done.

            If you have more specific need like specific dealing with spaces or something custom, try to explain in detail. Many things can be done even with regular expression replace.

          Best regards,
          Tomas.

          1 Reply Last reply Reply Quote 0
          • Jim DaileyJ
            Jim Dailey
            last edited by

            Also, you can use the Settings->Preferences->Editing dialog to have a vertical line displayed on screen to use as a guide. It will not automatically wrap the lines, but it will help you to wrap them.

            1 Reply Last reply Reply Quote 0
            • guy038G
              guy038
              last edited by guy038

              Hello Carl and All,

              Don’t be sad ! In addition to the suggestions of Tomas and Jim, there are TWO other means to get the job done. Indeed !

              • With a Search/replacement, using regular expressions ( I’ll explain two kinds of wrapping ).

              • With the N++ native split feature, by the menu option Edit - Line Operations - Split Lines.


              Let’s take an example, for better understanding. We’ll adopt some preliminary hypotheses, below :

              • Text is supposed to be “normal”. I mean, preferably, not language source code, lists in columns, poems or any specific text like these ones !

              • The blank character, used in text, is the classical SPACE character ( \x20 ). To be sure that this second hypothesis is verified, use the intelligent (Thanks to Loreia2 ! ) replacement of Tabulation characters by spaces ( Menu option Edit - Blank Operations - TAB to Space ), which keeps the original location of any NON blank character !

              • If your text is pure text, without any specific frame, you may perform this useful S/R, in Regular expression mode ( updated 07/14/16 ) :
                SEARCH = ^\h+|\h+$|(\h+) and REPLACE = (?1\x20), which :

                • Deletes any leading or trailing horizontal blank character ( either a Space, a Tabulation or a No-Break space )

                • Normalizes any, other, range of consecutive horizontal blank characters to an unique SPACE character ( \x20 )

              • Your current text, in Notepad++, is displayed WITHOUT wrapping. So, the menu option View - Word wrap must be UNCHECKED.

              • A vertical edge line, located between columns 40 and 41, is defined, in N++. To do so, select the menu option Settings - Preferences… - Editing. Then, in the middle of this dialog, check the Show vertical edge square box, choose the Line mode displaying, type the number 40 as columns number, and valid with the Enter key and a click on the Close button.


              OK. Now, let’s suppose that we want to split text, after 40 characters. Here is, below, the ORIGINAL example text that will be used. It begins by 5 test lines, from 38 to 42 characters long, followed by the section #7 of the license.txt file !

              12345678901234567890123456789012345678
              123456789012345678901234567890123456789
              1234567890123456789012345678901234567890
              12345678901234567890123456789012345678901
              123456789012345678901234567890123456789012
              
              7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
              
              If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
              
              It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
              
              This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
              

              If you want a STRICT splitting way, use, in regular expression search mode, the S/R, below :

              SEARCH = .{40}(?!\R) and REPLACE = $0\r\n

              =>Single words, exceeding 40 characters long, are split and paragraphs are wrapped, after, exactly, 40 characters !

              12345678901234567890123456789012345678
              123456789012345678901234567890123456789
              1234567890123456789012345678901234567890
              1234567890123456789012345678901234567890
              1
              1234567890123456789012345678901234567890
              12
              
              7. If, as a consequence of a court judgm
              ent or allegation of patent infringement
               or for any other reason (not limited to
               patent issues), conditions are imposed 
              on you (whether by court order, agreemen
              t or otherwise) that contradict the cond
              itions of this License, they do not excu
              se you from the conditions of this Licen
              se. If you cannot distribute so as to sa
              tisfy simultaneously your obligations un
              der this License and any other pertinent
               obligations, then as a consequence you 
              may not distribute the Program at all. F
              or example, if a patent license would no
              t permit royalty-free redistribution of 
              the Program by all those who receive cop
              ies directly or indirectly through you, 
              then the only way you could satisfy both
               it and this License would be to refrain
               entirely from distribution of the Progr
              am.
              
              If any portion of this section is held i
              nvalid or unenforceable under any partic
              ular circumstance, the balance of the se
              ction is intended to apply and the secti
              on as a whole is intended to apply in ot
              her circumstances.
              
              It is not the purpose of this section to
               induce you to infringe any patents or o
              ther property right claims or to contest
               validity of any such claims; this secti
              on has the sole purpose of protecting th
              e integrity of the free software distrib
              ution system, which is implemented by pu
              blic license practices. Many people have
               made generous contributions to the wide
               range of software distributed through t
              hat system in reliance on consistent app
              lication of that system; it is up to the
               author/donor to decide if he or she is 
              willing to distribute software through a
              ny other system and a licensee cannot im
              pose that choice.
              
              This section is intended to make thoroug
              hly clear what is believed to be a conse
              quence of the rest of this License.
              

              Now, you may prefer a “light” wrapping, that DOES NOT split words. So the splitting process will occur BETWEEN words ONLY !

              In that case, use, in regular expression search mode, the S/R, below :

              SEARCH = (.{1,40})(\h+\R?|\R) and REPLACE = \1\r\n

              => This time, single words, exceeding 40 characters long are NOT split and paragraphs of text are wrapped, between words. However, all resulting lines of text, after the five test lines, still, have, at the most, 40 characters.

              12345678901234567890123456789012345678
              123456789012345678901234567890123456789
              1234567890123456789012345678901234567890
              12345678901234567890123456789012345678901
              123456789012345678901234567890123456789012
              
              7. If, as a consequence of a court
              judgment or allegation of patent
              infringement or for any other reason
              (not limited to patent issues),
              conditions are imposed on you (whether
              by court order, agreement or otherwise)
              that contradict the conditions of this
              License, they do not excuse you from the
              conditions of this License. If you
              cannot distribute so as to satisfy
              simultaneously your obligations under
              this License and any other pertinent
              obligations, then as a consequence you
              may not distribute the Program at all.
              For example, if a patent license would
              not permit royalty-free redistribution
              of the Program by all those who receive
              copies directly or indirectly through
              you, then the only way you could satisfy
              both it and this License would be to
              refrain entirely from distribution of
              the Program.
              
              If any portion of this section is held
              invalid or unenforceable under any
              particular circumstance, the balance of
              the section is intended to apply and the
              section as a whole is intended to apply
              in other circumstances.
              
              It is not the purpose of this section to
              induce you to infringe any patents or
              other property right claims or to
              contest validity of any such claims;
              this section has the sole purpose of
              protecting the integrity of the free
              software distribution system, which is
              implemented by public license practices.
              Many people have made generous
              contributions to the wide range of
              software distributed through that system
              in reliance on consistent application of
              that system; it is up to the
              author/donor to decide if he or she is
              willing to distribute software through
              any other system and a licensee cannot
              impose that choice.
              
              This section is intended to make
              thoroughly clear what is believed to be
              a consequence of the rest of this
              License.
              

              Finally, we may, as well, use the split native feature of N++. In that case, use the menu option Edit - Line Operations - Split Lines, or with the CTRL + I shortcut. By default, ALL the current text is being split, but you can restrict the splitting process to a previous selection !

              However, to get a similar split text as above, you’d better increase by the number 2, the columns number, in the Preferences dialog. So, change 40 by 42, as columns number, in vertical Edge Settings.

              => In the resulting text, below, we notice that words, exceeding 41 characters long, are split and that text is wrapped, between words as above. But, unlike above, the different lines of a paragraph, except for the last one, ends, all, with a SPACE character !

              12345678901234567890123456789012345678
              123456789012345678901234567890123456789
              1234567890123456789012345678901234567890
              12345678901234567890123456789012345678901
              12345678901234567890123456789012345678901
              2
              
              7. If, as a consequence of a court 
              judgment or allegation of patent 
              infringement or for any other reason 
              (not limited to patent issues), 
              conditions are imposed on you (whether 
              by court order, agreement or otherwise) 
              that contradict the conditions of this 
              License, they do not excuse you from 
              the conditions of this License. If you 
              cannot distribute so as to satisfy 
              simultaneously your obligations under 
              this License and any other pertinent 
              obligations, then as a consequence you 
              may not distribute the Program at all. 
              For example, if a patent license would 
              not permit royalty-free redistribution 
              of the Program by all those who receive 
              copies directly or indirectly through 
              you, then the only way you could 
              satisfy both it and this License would 
              be to refrain entirely from 
              distribution of the Program.
              
              If any portion of this section is held 
              invalid or unenforceable under any 
              particular circumstance, the balance of 
              the section is intended to apply and 
              the section as a whole is intended to 
              apply in other circumstances.
              
              It is not the purpose of this section 
              to induce you to infringe any patents 
              or other property right claims or to 
              contest validity of any such claims; 
              this section has the sole purpose of 
              protecting the integrity of the free 
              software distribution system, which is 
              implemented by public license 
              practices. Many people have made 
              generous contributions to the wide 
              range of software distributed through 
              that system in reliance on consistent 
              application of that system; it is up to 
              the author/donor to decide if he or she 
              is willing to distribute software 
              through any other system and a licensee 
              cannot impose that choice.
              
              This section is intended to make 
              thoroughly clear what is believed to be 
              a consequence of the rest of this 
              License.
              

              To end with that topic :

              • Of course, Carl, any number, instead of the number 40, can be used, and, especially, 78.

              • The text, obtained by the light wrapping method, either with the regex S/R or the N++ Split feature, give the SAME resulting text if you want to get, in a second time, an UNIQUE line, with the N++ Join feature ( menu option Edit - Line Operations - Join Lines or CTRL + J shortcut ).

              Best Regards,

              guy038

              P.S. :

              If we consider the original short text, below and the need to wrap text after 40 characters :

              This is a test text, about the different wrapping methods.
              This text is quite short.
              It'll point out the slight differences between the splitting process !
              
              • With the S/R, SEARCH = (.{1,40})(\h+\R?|\R) and REPLACE = \1\r\n, we get the wrapped text, below :

                This is a test text, about the different
                wrapping methods.
                This text is quite short.
                It’ll point out the slight differences
                between the splitting process !

              We notice that lines, of exactly 40 characters long,( like the first one ), are NOT split and that the splitting process stops after any END of Line character(s).

              • With the N++ Split feature ( Edit - Line Operations - Split Lines ) and a vertical edge line, located after 42 columns, we get the wrapped text, below :

                This is a test text, about the
                different wrapping methods.
                This text is quite short.
                It’ll point out the slight differences
                between the splitting process !

              We notice that, when a line is exactly 40 characters long ( as the first line ), the last word is moved downwards, at beginning of the next line, due to the necessity to end each line by a space separator. But, as above, the splitting process stops after any END of Line character(s).

              • With the Split option of the TextFX plugin ( TextFX - TextFX Edit - ReWrap Text to (Clipboard or 72) width ), we get the wrapped text below :

                This is a test text, about the different
                wrapping methods. This text is quite
                short. It’ll point out the slight
                differences between the splitting
                process !

              This time, we notice that, like the S/R, lines of exactly 40 characters long, are NOT split, and, like the N++ split feature, each line ends the space separator. However, unlike above, the splitting process NEVER stops and goes on, over the consecutive lines of text !

              1 Reply Last reply Reply Quote 2
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors