How to set Notepad++ to display all opened files as NORMAL TEXT without coloring?
-
Hi
How to set Notepad++ to display all opened files as NORMAL TEXT without coloring?
-
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 itstylers-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 itstylers-02.xml
- Rename
stylers-01.xml
tostylers.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. :-)
- Make a copy of your
-
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
languageHowever note that, whatever the language, it takes lines in comments in account, as well as your version !
With the
Stylers.model
, of the pre-releasev8.6.5 - 64 bits
, I got1,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 lettera
! Luckily, the values of itsfg
andbg
attributes are, already, the default ones desiredWith the
Stylers.model
, of the pre-releasev8.6.5 - 64 bits
, I got1,292
replacementsBest Regards,
guy038
-
-
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++.
-
@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++
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. -
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 toATSTARTUP
- 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):
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).
-
@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.
-
@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”.
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.
-
@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.