Foreground options for Selected text?

  • HI - I just joined the community. I hope General Discussion is the right place for this query. I am new to Notepad++. I have been using Textpad for many years but I recently got fed up with them because they have never taken the rather obvious suggestion of allowing one to scroll font size up and down like almost every other Windows application. For aging eyes this is a must. I found Notepad++ does this and a whole lot more. I have spent some time in Style Configurator and am pretty happy with all the options, except that for some reason when I highlight or select any given text the font color or foreground remains the same. In most applications, as in Textpad, when you select text this applies the background color and the foreground goes to white. Even in the Style Configurator window itself, when any item under Style is selected the item is highlighted in blue and the text changes to white. It would be almost impossible to read it if it remained black. I’m working around this by using a fairly light color for highlighting, so I can still read the black through it, but I would prefer a darker highlighting with white font or foreground. Is this possible? Am I missing something? Thanks for any help here.

  • Hello jbrosecity,

    I don’t think that you can, easily, change the foreground colour of the selected text, ONLY. Indeed, the modification of the foreground colour is impossible, with the Style Configurator feature :-((

    As a work-around, of course, you may change the foreground colour of the Default Style style. If so :

    • To change the foreground colour of the normal text ( Selected or NOT ) :

      • Select the menu option Settings - Style Configurator…

      • Select the Default (stylers.xml) theme

      • Select the Global Styles language

      • Select the Default Style style

      • Click on the Foreground colour square, to choose a new colour

    • To change the background colour of the selected text

      • Select the menu option Settings - Style Configurator…

      • Select the Default (stylers.xml) theme

      • Select the Global Styles language

      • Select the Selected text colour style

      • Click on the Background colour square, to choose a new background colour

    • Finally, click on the Save & Close button, to save your changes

    Of course, if you currently use a theme, different from the default one, you’ll have to adapt this method !

    IF you prefer to change the colour of the selected text ONLY, you’ll have to exploit the Scintilla notification SCI_SETSELFORE

    Refer to the link below :

    In order to run that command, two solutions are available :

    • Use the NppExec plugin

      • Open the ^NppExec console

      • Type the command SCI_SENDMSG 2067 1 C, where :

        • C is the decimal result of the operation Blue * 65536 + Green * 256 + Red

        • Blue, Green, and Red are the value of each colour, in the range [0-255]

      • Hit the Enter key to valid this command

    For instance the command SCI_SENDMSG 2067 1 255, followed by Enter, will change the foreground colour of the text of any selection, in pure red. On the same way, you may change the background colour of the selection, with the command SCI_SENDMSG 2068 1 C

    • Use the Python Script plugin

    I’m not acquainted to Python Script yet, so I, just, can tell that you’ll have to use, in a new script, the two commands Editor.setSelFore(1, fore) and Editor.setSelBack(1, back), where, fore, and back are the decimal value, discussed above !

    Quite sure, that Claudia could do something about it !!

    Best Regards,


  • Thanks for the quick reply Guy. I tried the first suggestion to “change the foreground colour of the Default Style style.” but that did not accomplish the goal of changing the foreground colour to white within selected text. It remains black in HTML. It did however change the “=” (equal signs) in HTML to white which of course is not useful for HTML as they all then disappear against white page. So I changed it back. The Sintilla suggestion is way above my pay grade. I am just a lowly HTML coder… I don’t know a thing about programming or python or whatever.

    I did note of course that “foreground colour” is greyed out when using the “selected text color” option of the Global Styles. I think that is the shortcoming. As I said it is a default behavior in almost any windows utility or browser, when you select the text it changes color. Even in this field where I am typing this reply, If I doiubleclick on a word to select it, the text immediately changes color to white so it can more easily be read against the dark blue selection color. Standard stuff.

    So maybe Claudia could do something about this in the next release. Simply activating the “foreground colour” option out when using the “selected text color” would take care of it so if there is some reason why someone would NOT want the foreground colour to change in selected text they would have that option. In Textpad, this is indeed the case, and BOTH foreground colour and background colour are configurable in selected text.

    Thanks again…

  • Hi, jbrosecity,

    Oh, yes ! I just spoke about default normal text, only. Of course, with the usual HTML highlighting, the use of the Style Configurator… seems rather useless :-(( You could have a try, changing the foreground colour of the DEFAULT style of the HTML language, too, but I don’t think it’s worth to, unfortunately !

    But, using the Scintilla notification, and the example, given in my previous post, would change, for any language, the foreground colour of text, in a selection, of any tab of the active view ( main OR secondary ) to the red colour. So, it would overwrite the normal highlighting of any built-in or user language ! May be, it’s exactly the behaviour that you’re are looking for ?

    You may have a try ! Let’s go :

    • Download NppExec v0.5.3, from the link below Plugin v0.5.3/

    • Close any instance of Notepad++

    • Extract all the contents of this archive, in the plugins folder of your N++ configuration

    • Re-start Notepad++

    • Click on the new Show Console Dialog button of the Toolbar OR choose the menu option Plugins - NppExec - Show Console Dialog

    • In that NppExec console, just type the command SCI_SENDMSG 2067 1 C, where C is a number between 0 ( Black ) and 16777215 ( White ). You may choose the value 255 ( Pure Red ), to begin with !

    • Finally, select some text, in HTML or else, in the main editor. Do you like it ?

    If so, you’d better have a look to the NppExec help file, first, selecting the menu option Plugins - NppExec - Help/Manual. Remember that, with NppExec, you can write scripts and, also, run scripts on N++ start and/or N++ exit !

    If you still want to ask for this new feature, you should create a new pull request, at the address :

    But, I’m afraid that you’ll have to be patient, because some other requests should have a higher priority !



    P.S. :

    BTW, when I wrote :

    Quite sure, that Claudia could do something about it !!

    I just meant that Claudia is a definitive Python’s fan !! So, she’s certainly able to write a tiny script, to set this property for foreground selected text :-)) I may be mistaken, but I don’t think that Claudia Franck is part of the contributors’s team of N++

  • Hello @jbrosecity

    guy038 did it already. If you are just looking for a white foreground color (font) then the command is


    That’s it.
    To test it, download and install the python script plugin using plugin manager.
    Once done, start the python script console by using the menu Plugins->Python Script->Show Console
    and put this line into the textbox next to the Run button of the console.
    Press enter or Run button. Done. Now the selected Text should be in white.

    As said, this is for testing, a temporary solution. When you restart npp everything is reset to the old values.
    To make this persistant you need to add this line into the which has been automatically created
    during installation of the python script plugin.
    Therefore open the YOUR_INSTALLATION_PATH\Notepad++\plugins\PythonScript\scripts\ with
    npp and add the line on the end of the script.

    sys.stdout = editor    # <- this line already exists and should be the last line, as far as I remember

    But there is one more thing to do. You need to change the configuartion of python script plugin.
    Menu Plugins->Python Script->Configuration and change Initialisation from LAZY to
    ATSTARTUP. Restart npp. Now you should always have the white foreground color.

    So, basically two steps needs to be done.

    1. Edit
    2. Change startup mode

    @guy038 - 100% sure - I’m not a npp code contributor. If I would write c/c++ code it would be like
    giving a boy the RED button to play - not a good idea ;-) Thx for the kind words.


  • Well after going sailing all afternoon, I returned to find guy and Claudia’s posts. First I tried guy’s suggestion using ‘NppExec console’ using the command SCI_SENDMSG 2067 1 16777215 - but to no avail. Selected text still remains it’s original color beneath my medium blue select color. Then I tried Claudia’s solution installing the python plugin with the plugin manager. But every time I go to Plugins->Python Script->Show Console all I get is “unknown exception” - another epic fail. Searched my drive for and it doesn’t exist on my system. PythonScript.dll is there as is python.xml … but no py file. Sigh. I really appreciate everyone’s helpfulness… Reminds me of the old days of USENET, but as I said before, all this programming is way above my pay grade. I just piddle around with a little HTML code… probably should just go back to Textpad :-/

  • Hello jbrosecity,

    may I ask you which npp and windows version you use?
    An unknown exception can’t be the reason to give up, can it be? ;-)


  • @jbrosecity

    in case you have windows 10,
    I did some test with my win10 and found out,
    that installation via the plugin manager isn’t fully done.
    The subdirectories are missing. I assume permission problems, not yet verified.
    I downloaded the msi installer package, which you can get from here
    and run the installation. Worked, directories are created and
    show console works also.


  • Hi Claudia… I’m using NPP 6.8.8 and Windows 7, with. all current updates as of yesterday :-) By the way, for Guy’s suggestion, he neglected to say hit “enter” after entering the command "SCI_SENDMSG 2067 1 16777215 " in the NppExec console. For whatever reason I just tried it again and hit enter after pasting in the command and voila! the highlighted text above immediately went to white. NICE! Unfortunately it is temporary, apparently… You can run it each time you open NPP, I guess and closing the console I see still leaves the command in force, but not between sessions. I wish I could enter some line on one of the config files to make this the default behavior. I see that I can “Direct execute previous” with CTRL+F6 which is fairly automated, but it sure seems like a lot of trouble to go thru for something which is essentially a Windows standard feature. Even the world’s most featureless text editor, the ultra basic Notepad, exhibits this standard behavior. Hard to believe it was left out of something as sophisticated as NPP :-/

  • Claudia… WOW. I’m about to sign up for computer programming classes at the local junior college! I can’t believe I pulled this off! OK I saw your post about Windows 10, and as I said I’m using Win 7 but I thought what the heck so I downloaded your file and used the contents to overwrite what was previously installed with plugin manager. Then I was indeed able to open the python console, so I entered “editor.setSelFore(1,(255,255,255))” and lo and behold it made the text go white. So THEN searched for which came right up. It would not let me edit the file iC:\Program Files (x86)\Notepad++\plugins\PythonScript\scripts\, but I copied it to another directory, edited it there and then cipied I back over the one Prog Files and with “permission” it let me do it. Opening it again, sure enough the change took. Then finally I changed the Configuration Initialisation from LAZY to ATSTARTUP and voila! Now when I selected any text it acts just like Windows Notepad, Textpad, my browser and just about everything else and the selected text foreground changes to white! Thanks so much… This took wayyy too much time and energy but I can go to bed tonite with a real feeling of accomplishment. I’m gonna document all this in my notes for future installations, That was FUN! Übrigens, Claudia… Ihre Deutsch is viel besser wie meine mit Günter Leipfinger :-) Wenigens, habe Ich probiert!

  • Hello jbrosecity,
    I’m glad you’ve finished it. And after a day of sailing and programming (btw. I would bet that your html coding is much more
    complex than this one liner ;-)) you well-deserved the real feeling of accomplishment ;-) And it’s all about FUN, isn’t it.
    Regarding my german, well, what should I say - my father was german so it wasn’t that hard but your german
    is better than my english.


  • Claudia wrote : “but your german is better than my English.” Daß glaube Ich gar night! Danke vielmals, liebe Fraülein, oder soll Ich Gnädige Frau sagen? Jedenfalls, danke schoen… Ich bin jetzt froh weisses ‘text’ zu haben! Gute Nacht!

  • Hello jbrosecity,

    Ahhhhh! Of course, I forgot to tell you to hit the enter key, to valid the command. You know, it’s sometimes difficult to appreciate if we provide sufficient information, or NOT, while writing a post !

    Secondly, you surely didn’t notice it, but I said, in my previous post :

    Remember that, with NppExec, you can write scripts and, also, run scripts on N++ start and/or N++ exit !

    So, here’s, below, the method to, automatically, set the white colour to selected text, while opening Notepad++ :

    • Select the menu option Plugins - NppExec - Execute…, or type on the F6 key

    • Type the two lines, below, in the dialog :


      SCI_SENDMSG 2067 1 16777215

    • Save this script, with the name, let say, White_Selected

    • Select the menu option Plugins - NppExec - Advanced Options…

    • On the top right corner of this new dialog, choose your White_Selected script, under the mention Execute this script when Notepad++ starts:

    • Valid this change of the dialog, with the bottom OK button

    • Close and re-start N++

    Et voilà ! From now on, any selected text should be displayed with foreground white colour, even if the language of the current document has its own highlighting rules !

    Note : the NPP_CONSOLE ? command keeps the present state of the NppExec console. If it’s already opened, it will stay open, after running the script. If it’s was closed, it will remains closed

    Enjoy Notepad++ !!

    Best Regards,


    P.S :

    I’ve just noticed that you already got a solution, with the Python script plugin and Claudia’s help. So, now, you have two possible solutions ! Isn’t nice ?

  • Hiya Guy! Thanks for the alternate solution with the NppExec console. I saved Claudia’s python instructions to my programs notes file. I’ll add yours just because you took the time to type it up for me. And yes it IS fun to have multiple options. It is what I have always loved about computer software. If you can imagine it, you can do it! (Most of the time). While not a programmer at all, myself, I have run my own software business for nigh on 20 years now. Rose City Software. I am more of designer and marketer and have had the distinct pleasure of working with some great programmers over the years using C++, Delphi, and other languages… but they write the code, I just come up with and collect customer feedback for features and UI enhancements and then manage the sales and upgrades. It has been a fun and rewarding business the last couple decades and though semi retired now and traveling in my motorhome, I keep involved from my recliner with my laptop and a 4G Verizon connection. It keeps my mind active as I am just beginning my 8th decade. The rest of the time I just like to go sailing on my Catalina sailboat TheAnneMarie-dot-com :-) Thanks again Guy and Claudia… this has been a real pleasure!

  • I just checked back today to see if there had been anything new on this thread… and I see not. But I also see it has been the most often viewed thread in a while, so obviously there is some interest in this. I am grateful to Claudia and Guy for helping me get thru this, and with my selected text now appearing white against a dark blue background, I could not be happier with Notepad++. It was a fun challenge to set up python and jump through the hoops to get it to do this, but maybe the developers will take the clue and realize this is a major oversight, and there is plenty of interest in how to do this… and thus perhaps they will enable the option for foreground color with selected text in a future release. After all it is standard Windows behavior and virtually every other software I use, even the featureless Windows Notepad. handles selected text this way.

  • I would like to raise this old thread and ask - why so far the author not yet made this modification of the foreground colour in the Style Configurator?

Log in to reply