BUG: syntax highlighting not working
-
-
what file extension does your file have ?
-
how does your file behave, if you right click on it and select “edit with notepad++” instead of a double click ?
-
can you paste some of it’s content here using this template including the
```
code markers below and above your code ?
template:
``` your code here ```
-
-
Hello,
- It happens for any file extension, for example .htm
- After opening an empty Notepad++ instance:
- If I right-click on file and select “Open with notepad++”, syntax is highlighted
- If I drag-n-drop my file on Notepad++ window, syntax is highlighted
- If I double-click on my file, syntax is NOT highlighted
Furthermore: If I complete action 1 (not action 2), then I close the file (not the Notepad++ window), then action 3 colors the syntax (strange!)
- I cannot post an example of code because if I add it to this message the Akismet plugin on this website doesn’t allow me to post, sorry
-
i can not reproduce this.
all three ways to open an .html document display a correct highlighting on notepad++ 7.6.3 x86 and x64, on windows 7 and windows 10.
one thing you can try out on your 7.5.9:
-
close notepad++ if it is open
-
right click on your notepad++ icon and choose “run as administrator”
(make sure you see[Administrator]
at the top bar of your notepad++ window (see screenshot) -
go to
settings > preferences > file association
and make sure your needed extensions are visible at the registered extensions panel (last panel on the right) as seen on this screenshot:
-
hit close and exit notepad++
-
now reopen notepad++ normally, and go to
settings > preferences > file association
again, and make sure your needed extensions are also visible for the standard user account. -
then exit notepad++ again
-
right click on any .htm(l) file and choose
open with > choose other app
and select notepad++ from this list. -
select
always use this app to open .html files
and hit ok. -
close notepad++ again and retry opening your .htm file by double clicking on it.
-
-
Thank you for your kind support. I followed all the steps but no success.
After adding all “web script” extensions in Admin mode, if I reopen N++ in standard mode not all exetensions are added, but just some. So I added again all web extensions (this time in standard mode) and saved, then exited, then relaunched N++ but these extensions are still unselected (see screenshot https://imgur.com/a/xnlzeCL).
Apart from this, I think you cannot reproduce the bug because if you double-click on a file while N++ is closed, this bug doesn’t appear.You first have to open Notepad++ by clicking on its icon, then while keeping N++ program open (with no open files inside it), you have to double-click on an associated file (ie .htm).
If you follow this procedure you’ll probably see the bug. -
UPDATE: After these steps, now:
- PHP files display correctly
- ASP files open but are not syntax-highlighed
- HTM files do not open anymore
IMPORTANT: All these tests are performed with double-click and while an empty Notepad++ window is open). If N++ is closed, double-click works perfectly…
NOTE: In Administrator mode double-click and right-click work perfectly: files open and syntax is highlighted. Drag-n-drop does NOT work.
-
thank you for your detailed information @niente0
You first have to open Notepad++ by clicking on its icon, then while keeping N++ program open (with no open files inside it), you have to double-click on an associated file (ie .htm).
If you follow this procedure you’ll probably see the bug.i have not been able to reproduce this on windows 7 to 10 using notepad++ 7.5.5-7.6.3.
- open notepad with only a “new 1” tab (all documents closed) and keep it open and not minimised.
- double click on any registered file, like asp, htm, html, php, xml
- on my test setups, all files open and show the correct syntax highlighting, and the correct language type at the bottom of the status bar.
PHP files display correctly
ASP files open but are not syntax-highlighed
HTM files do not open anymore
…
in Administrator mode double-click and right-click work perfectly: files open and syntax is highlighted.this is very helpful, if the administrator mode works, highlighting everything correctly, probably only the current user (hkey_current_user at the registry) is affected.
also it’s a good sign that you can at least open php files with correct highlighting now.there are several, independent things you can try out, in no specific order, so freely choose what you like to do first, maybe any of it gives us more clues:
a)
- create a new, fresh user account on your machine and try out what happens if you open a file by registering the extension to notepad++ and double clicking it.
b)
- log in to your old user account, open regedit and search for
notepad++exe
- look for all instances where notepad++.exe is at a
shell\open\command
structure.
for example:HKEY_CLASSES_ROOT\Applications\notepad++.exe\shell\open\command
- the (default) value should be something like
"C:\Program Files (x86)\Notepad++\notepad++.exe" "%1"
where the path might be different on your system, but the important thing is, that your path to the exe as well as"%1"
is always between"
double-quotes
(not likeC:\Program Files (x86)\Notepad++\notepad++.exe %1
without quotes)
c)
- on your old user account, unregister one or more of the non highlighting file extensions using notepad++ (once at user level and once elevated, “run as administrator”)
- then reboot and register this/these file extensions again.
i hope any of this is of help, if not solving, but maybe pointing to any relevant direction.
reader’s note: if anyone else has ever experienced a similar issue and found a way to fix it, you are very welcome to join.
-
Thank you for your reply, I’ll try every hint you posted.
In the meantime, here’s a Notepad++ window showing two ASP files opened with 2 different methods: double-click with open N++ window on top, drag-n-drop at bottom -
It seems I finally found the culprit: searching into the registry I found some “shell/open/command” keys pointing to a Notepad++.exe installed on another drive (!).
It turned out that I had 2 different Notepads++ on 2 different drives!
So I removed one of them, then walked thru the registry to correct all paths, and now all works the right way!!!
I’ll do some more checks, but it seems my issue is solved!
Thanks again for your help. -
magnificent, i am glad you got it working. 👍
thank you for reporting this back, it will be of use for others who might experience the same problem.
if you have any further questions, we will assist you with pleasure. -
I had the same issue for PHP files.
The solution was to include the opening tag
<?
.The file I was using was just a scratch bit of PHP thus no tag was included. The same is true for HTML files. The opening tag,
<html
would be required.Languages like Javascript, SQL, etc., that don’t require tags work as expected.