• Login
Community
  • Login

Limit line length

Scheduled Pinned Locked Moved General Discussion
6 Posts 6 Posters 29.7k 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.
  • L
    Larry Bryan
    last edited by Jul 10, 2016, 4:05 PM

    Is there a way to limit line length? I use this program to read and create military message that have a line length limitation of 69 characters. I would like to be able to have the line wrap at that point so my text is the proper format. Can this be accomplished currently?

    L Bryan

    C 1 Reply Last reply Jul 12, 2016, 12:04 AM Reply Quote 0
    • N
      NotepadCpp
      last edited by Jul 11, 2016, 4:51 PM

      @Larry-Bryan Yes, it can. But you’re not going to like it.

      1. Open Notepad++ as Administrator.
      2. Go to Plugins > Plugin Manager > Show Plugin Manager.
      3. Under Available, locate “TextFX Characters”, check its little checkbox, and click [Install].
      4. Upon completion, a Dialog should append asking to restart: click [Yes].

      Ok. Now, you got the tool. Now, here’s how to format it to the 69 character limit.

      1. Hit Cntrl+n, type 69 into the new file, hit Cntrl+a then Cntrl+x, close the new file.
      2. Select (highlight) your message.
      3. Click TextFX on Notepad++ (it should be on menu-bar/top), then hover over “TextFX Editor”, and finally click “ReWrap…Clipboard or 72…” (it should be the second from the bottom).

      The tool wil now format your big long message into lines of 69 characters. The tool knew you copied 69 onto your clipboard so it read 69 and used 69 instead of 72.

      A 1 Reply Last reply Oct 24, 2021, 11:28 AM Reply Quote 0
      • C
        Claudia Frank @Larry Bryan
        last edited by Jul 12, 2016, 12:04 AM

        @Larry-Bryan

        Another solution would involve python script plugin and this script.

        WRAP_CHAR_COL = 69                                                                  # wrap lines after position WRAP_CHAR_COL
        EOL_CHARS = ['\r\n','\r','\n']                                                      # used to insert correct eol char
        
        _g = globals()                                                                      # global variable used to check status
        if not _g.get('CUSTOM_WRAP_IS_RUNNING'):                                            # if variable not defined yet,
            CUSTOM_WRAP_IS_RUNNING = False                                                  # set it to False (=NOT RUNNING)
                                                                                            
        # -----------------------------------------------------------------------------     
                                                                                            
        def callback_CHARADDED(args):                                                       # get called when char has been added
            current_position = editor.getCurrentPos()                                       # get current caret position
            if editor.getColumn(current_position) > WRAP_CHAR_COL:                          # if position is greater then WRAP_CHAR_COL
                word_position = editor.wordStartPosition(current_position, True)            # calculate start position of current word and
                eol_char = EOL_CHARS[editor.getEOLMode()]                                   # get eol char currently used.
                editor.insertText(word_position, eol_char)                                  # insert the eol char at the word start position
                editor.gotoPos(current_position + len(eol_char))                            # and move caret to new position
                                                                                            
        # -----------------------------------------------------------------------------     
                                                                                             
        def main():                                                                         # main function to handle start/stop behavior
            global CUSTOM_WRAP_IS_RUNNING                                                   # assining to global variable
            if CUSTOM_WRAP_IS_RUNNING:                                                      # if script is currently running
                editor.clearCallbacks([SCINTILLANOTIFICATION.CHARADDED])                    # clear registered callback,
                editor.setEdgeMode(False)                                                   # hide edge line and
                CUSTOM_WRAP_IS_RUNNING = False                                              # set flag to False
            else:                                                                           # else
                CUSTOM_WRAP_IS_RUNNING = True                                               # set the flag to true and
                editor.setEdgeColumn(WRAP_CHAR_COL)                                         # edge line position.
                editor.setEdgeMode(True)                                                    # show edge line and
                editor.callback(callback_CHARADDED, [SCINTILLANOTIFICATION.CHARADDED])      # register needed callback
                                                                                             
        # ----------------------------------------------------------------------------- 
                
        main()
        

        Comments describe what the script does. I assumed that you would break the whole word and not only by char.

        What needs to be done first is described here

        Just in case that you haven’t installed python script plugin yet, I would propose to use the MSI package instead of using the plugin manager.

        Cheers
        Claudia

        1 Reply Last reply Reply Quote 0
        • G
          guy038
          last edited by Jul 14, 2016, 11:37 PM

          Hello Larry,

          You could, also, have a look to my method, using regular expressions, at the address, below :

          https://notepad-plus-plus.org/community/topic/10642/how-do-i-get-the-file-to-wrap-the-line-at-78-characters/5

          Best Regards,

          guy038

          1 Reply Last reply Reply Quote 0
          • A
            achalk @NotepadCpp
            last edited by Oct 24, 2021, 11:28 AM

            @NotepadCpp The “TextFX Characters” Plugin no longer exists, apparently.

            P 1 Reply Last reply Oct 24, 2021, 5:43 PM Reply Quote 0
            • P
              PeterJones @achalk
              last edited by Oct 24, 2021, 5:43 PM

              @achalk ,

              Technically, it does still exist, but it is not maintained, and is only available for 32bit Notepad++ .

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