Community
    • Login

    How to set Notepad++ to display all opened files as NORMAL TEXT without coloring?

    Scheduled Pinned Locked Moved General Discussion
    9 Posts 5 Posters 1.3k 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.
    • PiotrMP006P
      PiotrMP006
      last edited by

      Hi

      How to set Notepad++ to display all opened files as NORMAL TEXT without coloring?

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @PiotrMP006
        last edited by

        @PiotrMP006

        Well, what I’m about to present doesn’t open non-“normal text” files as “normal text”, but it will show a technique for removing “coloring” (aka lexing) from all file/language types. Also, it assumes you are using non-Dark mode and want black lettering on a white background (i.e., fully assumes you are using the default theme).

        • Make a copy of your stylers.xml, perhaps call it stylers-01.xml
        • Open stylers-01.xml in Notepad++
        • Do a Replace All operation with this setup: Find what: (?-si:<LexerStyles>|(?!\A)\G)(?s-i:(?!</LexerStyles>).)*?\K(?-si:fgColor=".{6}" bgColor=".{6}") / Replace with: fgColor="000000" bgColor="FFFFFF" / checkmark only: Match case, Wrap around, Regular expression
        • Save
        • Exit Notepad++
        • Rename your stylers.xml, perhaps call it stylers-02.xml
        • Rename stylers-01.xml to stylers.xml
        • Start Notepad++

        Note: if something gets screwed up, you still have your original file in stylers-02.xml.

        Probably there are easier ways to achieve the goal, but I thought this way was kind of a “fun” way. :-)

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

          Hello, @piotrMP006, @alan_kilborn and All,

          Alan, your regex does change some colors in the Search Result language. I suppose that this fact is not desired by the OP ! So, this modified regex S/R should work :

          • SEARCH (?-si:<LexerStyles>|(?!\A)\G)(?s-i:(?!<LexerType name="searchResult").)*?\K(?-si:fgColor=".{6}" bgColor=".{6}")

          • REPLACE fgColor="000000" bgColor="FFFFFF"

          This version does not take in account any line of the Search result language

          However note that, whatever the language, it takes lines in comments in account, as well as your version !

          With the Stylers.model, of the pre-release v8.6.5 - 64 bits, I got 1,297 replacements


          After enumeration, we may notice that the lines, that need to be changed, have all a name attribut with :

          • An uppercase letter or a # symbol, as first character

          • An uppercase letter, a digit, a space or a dash char, as second character

          Thus, an other solution is, simply, the following S/R :

          • SEARCH (?-is)^\h+<WordsStyle name="[\u#][\u\d -].+?".+\KfgColor=".{6}" bgColor=".{6}"

          • REPLACE fgColor="000000" bgColor="FFFFFF"


          This solution :

          • Does not consider the lines in comments

          • But it misses the line below, in the Postscript language :

                      <WordsStyle name="Name" styleID="5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
          

          Just because the attribut Name has a value where the second character is the lowercase letter a ! Luckily, the values of its fg and bg attributes are, already, the default ones desired

          With the Stylers.model, of the pre-release v8.6.5 - 64 bits, I got 1,292 replacements

          Best Regards,

          guy038

          1 Reply Last reply Reply Quote 0
          • CoisesC
            Coises
            last edited by

            I’m not very familiar with the scripting plugins, but I think this would be easily done using PythonScript with something like:

            def setLanguage(args):
                notepad.setLangType(LANGTYPE.TXT, args["bufferID"])
            
            notepad.callback(setLanguage, [NOTIFICATION.FILEOPENED])
            

            That way you could still set the language manually, but all newly opened files would default to plain text.

            Hopefully someone more familiar than I with Python and the scripting plugin will say whether this is the right way to do it and can guide you to the least painful way to get it set up. I believe there is a simple way to put it where it will take effect every time you start Notepad++.

            EkopalypseE Alan KilbornA 2 Replies Last reply Reply Quote 4
            • EkopalypseE
              Ekopalypse @Coises
              last edited by

              @Coises said in How to set Notepad++ to display all opened files as NORMAL TEXT without coloring?:

              I believe there is a simple way to put it where it will take effect every time you start Notepad++

              @PiotrMP006

              That would mean creating a file called startup.py and
              do NOT use the file that comes with the plugin itself. Create your own file. It will be created in a different path and, unlike the supplied file, will survive a possible plugin update.

              1 Reply Last reply Reply Quote 3
              • Alan KilbornA
                Alan Kilborn
                last edited by Alan Kilborn

                To put together @Coises and @Ekopalypse replies…

                • Select New script from the Plugins > Python Script menu
                • When prompted, type startup.py for the name of the script
                • Copy and Paste @Coises 's script into the editor, and Save
                • Select Configuration from the Plugins > Python Script menu, and change the box with LAZY in it to ATSTARTUP
                • Restart Notepad++

                The new user-startup file will be visible in the menu system here (but NEVER needs to be executed via the menus, it will run automatically when N++ starts up the PS plugin):

                d6be23b8-a053-43ff-b3ce-229eaa1d82a1-image.png

                The screenshot is meant to hammer home the point @Ekopalypse was making about there potentially being some confusion about 2 startup files (with identical names in the file system – in the PS menus they are different though).

                1 Reply Last reply Reply Quote 2
                • Alan KilbornA
                  Alan Kilborn @Coises
                  last edited by Alan Kilborn

                  @Coises said :

                  I’m not very familiar with the scripting plugins, but I think this would be easily done using PythonScript with something like… all newly opened files would default to plain text.

                  It’s a reasonable solution, although OP talked only about neutering “colors”. Setting a file to normal-text will also eliminate stuff like “folding” (for languages/extensions that have that) which the OP did not mention wanting to exclude – but it is probably reasonable to conclude that they don’t care about such things.

                  CoisesC 1 Reply Last reply Reply Quote 2
                  • CoisesC
                    Coises @Alan Kilborn
                    last edited by

                    @Alan-Kilborn said in How to set Notepad++ to display all opened files as NORMAL TEXT without coloring?:

                    It’s a reasonable solution, although OP talked only about neutering “colors”.

                    @PiotrMP006:

                    If that’s all that’s wanted, won’t making the desired settings at:

                    Settings | Style Configurator | Global Styles | Global override

                    do it? Just check the Enable global … boxes for everything you want to keep constant, and then set the Colour Style and Font Style as desired.

                    Alan KilbornA 1 Reply Last reply Reply Quote 3
                    • Alan KilbornA
                      Alan Kilborn @Coises
                      last edited by

                      @Coises said in How to set Notepad++ to display all opened files as NORMAL TEXT without coloring?:

                      Just check the Enable global

                      It may be the best suggestion yet, owing to its simplicity.
                      Only the OP knows for sure what they want; if they don’t return to comment, we won’t know.

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