File Specific word wrap (vs. global enable)

  • Hi Claudia,

    I’ve just installed the Python Script plugin, on the last v6.8.8 version and I tested your script, choosing successively a particular property : It worked nice !

    Of course, we get, from time to time, some weird effects. One example :

    I previously changed your script, in order to ONLY use the Word Wrap feature ( I put the other lines in comments )

    I suppose that the Word wrap is UNSET, on starting N++, and that it contains four opened tabs

    • Select tab #2 and run your script, then select tab #4 and run your script again. Well, if you select from tab #1 to #4, tabs #2 and #4 have the property Word wrap ENABLED and tabs #1 and #3 DON’T. Logical !

    • Then, click again on tab #2 and run your script => all the tabs seem to have the Word Wrap DISABLED ?

    • Finally, click, a last time, on tab #2 and run your script => Again the tab #2 ( as well as tab #4 !! ) have, again, the property Word Wrap ENABLED :-))

    There are some other cases like that. However, Claudia, it doesn’t matter. The main fact is that a displaying property, which is managed, on the whole, by N++, for all the opened files, can be set, with a Python script, individually, for 1 or few files ONLY :-))

    This valuable script may be useful, from time to time. Many thanks, for your “Python” work !



  • Hi guy038,

    your welcome but you are right, strange, need to dig deeper to see what happens there.
    Let’s see if we find the bug ;-)


  • Hello guy038,

    I guess I found the problem and a work around because
    I’m not 100% convinced of this solution.

    I did some additional console.write statement wihtin the code and found out,
    that the notepad callback needs to be set once only. Indeed it was the source of the
    problem as it seems that it has confused the python script plugin.

    So what needs to be done is to comment (or delete) the following lines

    # if editor.getProperty('callback_already_set') != '1':
        # editor.setProperty('callback_already_set', '1')
        # notepad.callback (npp_callback_BUFFERACTIVATED, [NOTIFICATION.BUFFERACTIVATED ])
        # console.write('{0}\n'.format('callback registered'))
    # else:
        # notepad.clearCallbacks([NOTIFICATION.BUFFERACTIVATED])
        # editor.setProperty('callback_already_set', '0')
        # console.write('{0}\n'.format('callback deleted'))

    and add the line before or afterwards the commented block.

    notepad.callback (npp_callback_BUFFERACTIVATED, [NOTIFICATION.BUFFERACTIVATED ])

    The changes do have a drawback so, it means that the script doesn’t do the clearcallback anymore.
    Not sure if this is an issue but if so, you can always run


    from python script console or restart npp. ;-)


  • Hi Claudia,

    I tested your changed script. It woks great, indeed ! Referring to my last try, each time I ran this new version of your script, the state of the word wrap option, for the current file was changed into the opposite state, even, when using two simultaneous views !

    And, when running the command, below :


    In the Python console, I noticed that it sets the Word wrap state of the current document of each view, to all the opened documents of that associated view !

    Of course, after using the Python script, you can’t, seriously, rely on the visual appearance, of the Word Wrap button and/or the v indication, in menu View - Word wrap, as well as a click action, on this button/option !

    Just remember to use the Claudia script, exclusively, to get the right state of the Word Wrap ( or an other property ! ) that you want, for the current document !

    Thanks again, Claudia, for that nice Notepad++'s improvement !



    P.S :

    However, there’s, still, a limitation. For instance, if your create two ( almost ) identical scripts :

    • The first one, to modify a displaying property of the current document

    • The second one, to modify an OTHER property, of the current document

    The python script get confused and the properties can’t be set, simultaneously. Rather normal, however. We just have to be aware about this fact !

  • @Claudia-Frank 's FIRST Pythonscript in this thread really shines if the Wrap status is added to the status bar using the technique shown in the following thread: In that thread, the read-only status of the current file is shown (based upon a script in yet-another thread…sorry), but that can be modified to show the wrap status as follows:


    line_col_sel_info_for_sb = 'Ln : {user_line}     Col : {user_col}     Sel : {sel}     {ro}r'.format(
        ro='+' if editor.getReadOnly() else '-'


    line_col_sel_info_for_sb = 'Ln : {user_line}     Col : {user_col}     Sel : {sel}     {w}'.format(
        w='W' if editor.getWrapMode() == 1 else ''  # show 'W' in status bar if wrap mode is on for this file

  • Scott,

    don’t dig to deep to find my all of my youthful follies. ;-)


  • @Claudia-Frank

    Yea, I can tell that is earlier code from you, but it works!

  • I know this topic old but I tried the referenced solution and could not get it to work.
    I went to PLUGINS > PYTHON SCRIPT > NEW SCRIPT and saved the example code as file_word_wrap.

    I also added …
    <Item PluginEntryName=“Python Script” PluginCommandItemName=“file_word_wrap” />
    … at the bottom of contextMenu.xml as instructed but did not see it as a right-click option.

  • Hi @Clyfton-In , All:

    I also know that this topic is old, but tried today the python script and it worked fine for me.

    The following picture includes the relevant code and highlights the status bar zone that shows the requested info:



  • The Pythonscript is great and all, but this surely feels like something that should be offered as a feature in stock Notepad++. My 2c.

  • @Alan-Kilborn

    I think so. I also think that the regex indicators —not shown in my picture— are a nice and helpfull add-on.

  • @astrosofista said in File Specific word wrap (vs. global enable):

    regex indicators

    What “regex indicators” are you referring to? Did I miss something?

  • @Alan-Kilborn said in File Specific word wrap (vs. global enable):

    @astrosofista said in File Specific word wrap (vs. global enable):

    regex indicators

    What “regex indicators” are you referring to? Did I miss something?

    Sorry, my wording wasn’t clear enough. I was referring to the regex metacharacters that Scott Sumner used to enrich the info about the selected characters and lines. They are listed here:

    link text

Log in to reply