Notepad++ 8.4.2 not recognizing file extension to define language
-
It works for me. If I open
filename.php
with v8.4.2, it recognizes it as a PHP file. And if I openphp.misnamed
that starts with<?php
, Notepad++ v8.4.2 still recognizes it, because it does do first-line parsing for identifying files.If your window is wide enough, the status bar at the bottom will show the name of the current lexer:
(this is true whether or not you have “global foreground colour” or something else interfering with the colors)Given that you say it’s loading as a “user-defined” language, I suggest you go through your list of user-defined languages, and make sure none of them define the PHP extension, because that’s the only thing I’ve run across that would cause the symptoms that you’ve described.
-
I made a new file that only has
<?php
and called it demo.php
When I open it it’s still user defined.I’ve never made a user-defined language, but user-defined language folder has markdown._preinstalled.udl.xml and markdown._preinstalled_DM.udl.xml, which are both on my language list
my status bar shows:
Do I just delete the 2 preinstalled UDLs in the folder?
-
As those 2 are “predefined” I think removing them will do nothing for your situation.
FWIW I tried Peter’s experiment with php.misnamed and obtained his exact results with it.
-
The status bar disagrees with your Language menu. Your status bar shows you have a UDL called “ILE=MANDALORE”, which means it has nothing to do with the Markdown UDLs (and apparently something to do with Star Wars, though I would have thought it would be “ILM=MANDALORE” in that case ;-) )
Please check the Language > User Defined Language > Define Your Language…, which will pop up a dialog (or a docked windows, depending on if you’ve docked it). It will have a pulldown that lets you pick the language, like
Select each entry in that list, and make sure that the Ext.: box doesn’t contain
php
-
@peterjones said in Notepad++ 8.4.2 not recognizing file extension to define language:
and apparently something to do with Star Wars, though I would have thought it would be “ILM=MANDALORE” in that case ;-) )
I wonder how many people understand that reference; maybe just us oldsters. :-)
-
@pallieguy said in Notepad++ 8.4.2 not recognizing file extension to define language:
and called it demo.php
When I open it it’s still user defined.When you are saying “open”, do you mean “when I launch Notepad++ and the saved session includes
demo.php
” or do you mean “when I closedemo.php
and then use File>Open or equivalent to open thedemo.php
, it still says it is user defined”Because if you manually selected “user defined” (either intentionally or on accident) for
demo.php
and exit Notepad++ without closing, and if you have “remember current session for next launch” enabled, then when Notepad++ writes thesession.xml
file, it saves the UDL that you had assigned to an open file. Until you actually close the file before exiting Notepad++, the application will continue to remember your manual UDL choice. -
@peterjones
Mandalore is what my computer is named. Your pun made me laugh out loud and my Girlfriend called me a nerd.When I close demo.php and go File > Open or double click on the file in my Windows Explorer window (N++ is my default) then the language is not identified. If I launch notepad any saved sessions keep the language I’ve identified.
Under Language > User Defined Language > Define Your Langauge… I see the following:
I thought I might have clicked something, but I’m trying brand new files and they’re not doing it.
-
Okay, so I jsut tried opening a CSS file and it recognized it as CSS and now my php files are being recognized. I’m not sure if it was opening the User Defined Languages popup or opening the CSS file, but something in there fixed my issue.
Strange…
-
@pallieguy said in Notepad++ 8.4.2 not recognizing file extension to define language:
any saved sessions keep the language I’ve identified.
Indeed, that is the way it works. The session files track the Language selected for each file – so that way if you’ve manually selected a language for a file, it will keep it from run-to-run as long as you don’t close the file in Notepad++. And if you had saved a separate session file (File > Save Session…) then that UDL information was saved in that file, so any time you load that session file, it will keep that UDL information with the file. Other
*.php
files, and any file like thephp.misnamed
which starts with<?php
will determine the type as PHP when you do the File > Open on them; but if you have a PHP file in a session and had saved that session with something other than PHP selected, it will remember that. Resave your session now thatdemo.php
is identified as a PHP, and your problem will not come back to haunt you. -
Hello
I recently had a similar “issue” with other type of source files and only if I open the file from file explorer and not from File->Open.
For example .py, .md, .txt, .json, etc. files (with extension).
When they are opened from File->Open or File->Recent the language is detected and is correctly visible on the left side of status bar.
When they are opened from file explorer in all cases the language is not detected and in status bar is see the followingI have a couple of UDLs but all mentioned file types-extensions should not be affected.
Notepad++ v8.4.2 (64-bit)
Build time : May 29 2022 - 16:47:30
Path : C:\Users~~\Apps\Notepad++\notepad++.exe
Command Line :
Admin mode : OFF
Local Conf mode : ON
Cloud Config : C:\Users~~\Apps\Notepad++\cloudDir
OS Name : Windows 10 Pro (64-bit)
OS Version : 21H2
OS Build : 19044.1766
Current ANSI codepage : 1252
Plugins :
ComparePlugin (2.0.2)
DSpellCheck (1.4.24)
EnhanceAnyLexer ()
Explorer (1.9.5)
GitSCM (1.4.7.1)
MarkdownViewerPlusPlus (0.8.2)
mimeTools (2.8)
NppConverter (4.4)
NppExport (0.4)
NPPJSONViewer (1.40)
NppXmlTreeviewPlugin (2)
PoorMansTSqlFormatterNppPlugin (1.6.13.31508)
SurroundSelection (1.4.1) -
Given that your status bar shows path or file/machine information in the “file type” section like @Pallieguy showed, I now think you have found something… however, I am not able to replicate it with my installation of Notepad++.
If I use the Windows Explorer and use the double-click action (on file types like
.txt
and.md
, which have their default action set to Notepad++), it loads them up and immediately recognizes the type; and if I use my right-click Edit with Notepad++ action on any file type (those listed, or.py
or.json
, to finish replicating your examples), it also correctly recognizes the type: it does not pick a non-existent UDL and show part of the file path in the status bar.Notepad++ v8.4.2 (64-bit) Build time : May 29 2022 - 16:47:30 Path : C:\usr\local\apps\notepad++\notepad++.exe Command Line : "C:\Users\xxxxx\Downloads\TempData\23148.txt" Admin mode : OFF Local Conf mode : OFF Cloud Config : OFF OS Name : Windows 10 Enterprise (64-bit) OS Version : 20H2 OS Build : 19042.1586 Current ANSI codepage : 1252 Plugins : AutoSave (1.6.1) ComparePlugin (2.0.2) DSpellCheck (1.4.24) EnhanceAnyLexer () ExtSettings (1.2.1) MarkdownViewerPlusPlus (0.8.2) mimeTools (2.8) NppConsole (1.2.4.1) NppConverter (4.4) NppEditorConfig (0.4) NppExec (0.8) NppExport (0.4) NppFTP (0.30.12) NppLspClient () NppUISpy (1.0.4) PreviewHTML (1.3.2) PythonScript (2) QuickText (0.2.4.1) TagLEET (1.3.10.1) _CustomizeToolbar (5.3)
I wonder if there’s some difference in the way our file associations are defined which are causing the difference between your installation’s behavior and mine… Weird. If you can provide more information (how you made your associations, or digging into the registry to show us exactly what those associations look like), it might provide enough hints to make a replicable situation: if we can replicate it and define the exact sequence of events necessary, then we can probably file a bug report about it; but without a way to replicate it, I am not sure that a bug report will get much activity after the first attempt to replicate it fails.
-
@peterjones
I booted up my computer today and I’m now getting the behavior described by @Giannis-Raptis. If I go File > Open it detects the language, if I right click in explorer and select Edit with Notepad++ it detects the language, if I select the file from the recent files section under the File menu it detects the language. The only way it doesn’t is if I double click the file in Windows Explorer.I’ve tried my hardest to avoid dealing with the windows registry. If you can let me know what details you need I’ll gladly get you what I can.
-
Here’s a way to do it where you cannot accidentally write anything: using the command-line REG QUERY which just grabs information from the registry without editing it. (For these instructions, I am assuming that even double-clicking a
*.txt
file is giving this wrong behavior. If not, replace the.txt
below with an extension that double-clicks into Notepad++ but doesn’t identify correctly, like maybe.php
, since that’s what started it all.)Open a command prompt
REG QUERY HKCR\.txt /VE
This will output something like:
HKEY_CLASSES_ROOT\.txt (Default) REG_SZ txtfile
Whatever the text is to the right of
REG_SZ
, use that in the next query:REG QUERY HKCR\txtfile
Share those results with us (use the
</>
button on the forum toolbar to wrap your text in a black box like I did)For example, mine is:
C:\usr\local\share>REG QUERY HKCR\.txt /VE HKEY_CLASSES_ROOT\.txt (Default) REG_SZ txtfile C:\usr\local\share>REG QUERY HKCR\txtfile HKEY_CLASSES_ROOT\txtfile (Default) REG_SZ Text Document EditFlags REG_DWORD 0x210000 FriendlyTypeName REG_EXPAND_SZ @%SystemRoot%\system32\notepad.exe,-469 HKEY_CLASSES_ROOT\txtfile\DefaultIcon HKEY_CLASSES_ROOT\txtfile\shell
Those will give the “old fashioned” file associations, which Windows used prior to Win10 (and still work in Win10 and Win11, though they are moving away from them)
But since @giannis-raptis is on Win10, it might be useful to examine the newer “Open With” storage locations
REG QUERY HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt /S REG QUERY HKCR\Applications\notepad++.exe /S
Give us the output to both of those as well
For the record, mine are:
C:\usr\local\share>REG QUERY HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt /S HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\OpenWithList a REG_SZ notepad.exe b REG_SZ cabd c REG_SZ EXCEL.EXE d REG_SZ notepad++.exe MRUList REG_SZ dce e REG_SZ chrome.exe HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\OpenWithProgids txtfile REG_NONE HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\UserChoice ProgId REG_SZ Applications\notepad++.exe Hash REG_SZ cK5ueCMWhb4= C:\usr\local\share>REG QUERY HKCR\Applications\notepad++.exe /S HKEY_CLASSES_ROOT\Applications\notepad++.exe FriendlyAppName REG_SZ Notepad++ (Default) REG_SZ Notepad++ Text Document HKEY_CLASSES_ROOT\Applications\notepad++.exe\DefaultIcon (Default) REG_SZ "c:\usr\local\apps\notepad++\notepad++.exe",-100 HKEY_CLASSES_ROOT\Applications\notepad++.exe\shell HKEY_CLASSES_ROOT\Applications\notepad++.exe\shell\open Icon REG_SZ c:\usr\local\apps\notepad++\notepad++.exe,-101 HKEY_CLASSES_ROOT\Applications\notepad++.exe\shell\open\command (Default) REG_SZ "C:\usr\local\apps\notepad++\notepad++.exe" "%1"
And finally, grab
REG QUERY HKCU\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts
But that’s too big. So paste it into Notepad++, and then run the following replacement on it:
- FIND WHAT:
(?-s)^((?!Toasts|Notepad\+\+\.exe|\.txt).)*(\R|\Z)
- REPLACE WITH: (empty)
- hit Replace All
Then copy/paste the filtered results from Notepad++ into a black
</>
box in your your reply as well. - FIND WHAT:
-
@peterjones
I tried a .txt to see if the language problem persisted and like after the .css yesterday, the language is back to being detected properly for all my files. If it happens again tomorrow I will run these commands and post them while it’s still wonky.First set of commands:
C:\Users\Palli>REG QUERY HKCR\.php /VE HKEY_CLASSES_ROOT\.php (Default) REG_SZ php_auto_file C:\Users\Palli>REG QUERY HKCR\php_auto_file HKEY_CLASSES_ROOT\php_auto_file\shell
Second two:
C:\Users\Palli>REG QUERY HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.php /S HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.php\OpenWithList a REG_SZ firefox.exe b REG_SZ cab c REG_SZ {1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\OpenWith.exe d REG_SZ dabc MRUList REG_SZ eabcd e REG_SZ notepad++.exe HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.php\OpenWithProgids php_auto_file REG_NONE HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.php\UserChoice Hash REG_SZ 8c5Dq+bAc2A= ProgId REG_SZ Applications\notepad++.exe C:\Users\Palli>REG QUERY HKCR\Applications\notepad++.exe /S HKEY_CLASSES_ROOT\Applications\notepad++.exe\shell HKEY_CLASSES_ROOT\Applications\notepad++.exe\shell\open HKEY_CLASSES_ROOT\Applications\notepad++.exe\shell\open\command (Default) REG_SZ "D:\Notepad++\notepad++.exe" "%1"
Filtered last command:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts txtfile_.txt REG_DWORD 0x0 textfile_.txt REG_DWORD 0x0 Applications\notepad++.exe_.sfv REG_DWORD 0x0 Applications\notepad++.exe_.srt REG_DWORD 0x0 Applications\notepad++.exe_.ssa REG_DWORD 0x0 soffice.StarWriterDocument.6_.txt REG_DWORD 0x0 soffice.StarCalcDocument.6_.txt REG_DWORD 0x0 Applications\notepad++.exe_.txt REG_DWORD 0x0 Applications\notepad++.exe_.php REG_DWORD 0x0 Applications\NOTEPAD.EXE_.txt REG_DWORD 0x0 Applications\notepad++.exe_.gcode REG_DWORD 0x0 Applications\notepad++.exe_.pl REG_DWORD 0x0 Applications\notepad++.exe_.css REG_DWORD 0x0 Applications\notepad++.exe_.js REG_DWORD 0x0 Applications\notepad++.exe_.orig REG_DWORD 0x0 Applications\notepad++.exe_.ini REG_DWORD 0x0 Applications\notepad++.exe_.log REG_DWORD 0x0 Applications\notepad++.exe_.fasta REG_DWORD 0x0 Applications\notepad++.exe_.htaccess REG_DWORD 0x0 Applications\notepad++.exe_.cpp REG_DWORD 0x0 Applications\notepad++.exe_.h REG_DWORD 0x0 Applications\notepad++.exe_.cfg REG_DWORD 0x0 Applications\notepad++.exe_.pem REG_DWORD 0x0 Applications\notepad++.exe_.html REG_DWORD 0x0 Applications\notepad++.exe_.json REG_DWORD 0x0 Applications\notepad++.exe_.lock REG_DWORD 0x0 Applications\notepad++.exe_.gitignore REG_DWORD 0x0 AppX4ztfk9wxr86nxmzzq47px0nh0e58b8fw_.txt REG_DWORD 0x0 Applications\notepad++.exe_.test REG_DWORD 0x0 Applications\notepad++.exe_.old REG_DWORD 0x0 Applications\notepad++.exe_.new REG_DWORD 0x0 Applications\notepad++.exe_.xml REG_DWORD 0x0 Applications\notepad++.exe_.bar REG_DWORD 0x0 Applications\notepad++.exe_.htpasswd REG_DWORD 0x0 Applications\notepad++.exe_.env REG_DWORD 0x0
-
I wonder if one of your plugins is causing Notepad++ to have intermittent difficulty in identifying the file type. Weird. If it goes back to happening, share your ?-menu’s Debug Info like @Giannis-Raptis did.
Also, if it happens again, try closing Notepad++ and renaming your
c:\program files\notepad++\plugins
directory (which is one of the steps in this FAQ, which though it claims to be about crashing, is also a general-purpose see-if-plugin-is-causing-problem instruction set; because your problem is only with double-click, you cannot easily use option #1, but option #2 will still work for you) -
This post is deleted! -
@peterjones
I haven’t installed any plugins that I’m aware of, but I’ll try that after posting if it happens again tomorrow.Debug info:
Notepad++ v8.4.2 (64-bit) Build time : May 29 2022 - 16:47:30 Path : C:\Program Files\Notepad++\notepad++.exe Command Line : "D:\Dropbox (xxxx)\xxxx\Coding\xxxx\web\content\submissions\permissionForm\index.php" Admin mode : OFF Local Conf mode : OFF Cloud Config : OFF OS Name : Windows 10 Pro (64-bit) OS Version : 21H2 OS Build : 19044.1766 Current ANSI codepage : 1252 Plugins : mimeTools (2.8) NppConverter (4.4) NppExport (0.4)
-
@pallieguy said in Notepad++ 8.4.2 not recognizing file extension to define language:
I haven’t installed any plugins that I’m aware of
Your Debug Info agrees: you only have the default plugins, which aren’t the culprit.
Well, let us know if the problem comes back.
-
@peterjones
Day three and the same problem. Only difference is I didn’t shut down the computer last night.First commands:
C:\Users\Palli>REG QUERY HKCR\.php /VE HKEY_CLASSES_ROOT\.php (Default) REG_SZ php_auto_file C:\Users\Palli>REG QUERY HKCR\php_auto_file HKEY_CLASSES_ROOT\php_auto_file\shell
Second Set:
C:\Users\Palli>REG QUERY HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.php /S HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.php\OpenWithList a REG_SZ firefox.exe b REG_SZ cab c REG_SZ {1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\OpenWith.exe d REG_SZ dabc MRUList REG_SZ eabcd e REG_SZ notepad++.exe HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.php\OpenWithProgids php_auto_file REG_NONE HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.php\UserChoice Hash REG_SZ 8c5Dq+bAc2A= ProgId REG_SZ Applications\notepad++.exe C:\Users\Palli>REG QUERY HKCR\Applications\notepad++.exe /S HKEY_CLASSES_ROOT\Applications\notepad++.exe\shell HKEY_CLASSES_ROOT\Applications\notepad++.exe\shell\open HKEY_CLASSES_ROOT\Applications\notepad++.exe\shell\open\command (Default) REG_SZ "D:\Notepad++\notepad++.exe" "%1"
Filtered last command:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts txtfile_.txt REG_DWORD 0x0 textfile_.txt REG_DWORD 0x0 Applications\notepad++.exe_.sfv REG_DWORD 0x0 Applications\notepad++.exe_.srt REG_DWORD 0x0 Applications\notepad++.exe_.ssa REG_DWORD 0x0 soffice.StarWriterDocument.6_.txt REG_DWORD 0x0 soffice.StarCalcDocument.6_.txt REG_DWORD 0x0 Applications\notepad++.exe_.txt REG_DWORD 0x0 Applications\notepad++.exe_.php REG_DWORD 0x0 Applications\NOTEPAD.EXE_.txt REG_DWORD 0x0 Applications\notepad++.exe_.gcode REG_DWORD 0x0 Applications\notepad++.exe_.pl REG_DWORD 0x0 Applications\notepad++.exe_.css REG_DWORD 0x0 Applications\notepad++.exe_.js REG_DWORD 0x0 Applications\notepad++.exe_.orig REG_DWORD 0x0 Applications\notepad++.exe_.ini REG_DWORD 0x0 Applications\notepad++.exe_.log REG_DWORD 0x0 Applications\notepad++.exe_.fasta REG_DWORD 0x0 Applications\notepad++.exe_.htaccess REG_DWORD 0x0 Applications\notepad++.exe_.cpp REG_DWORD 0x0 Applications\notepad++.exe_.h REG_DWORD 0x0 Applications\notepad++.exe_.cfg REG_DWORD 0x0 Applications\notepad++.exe_.pem REG_DWORD 0x0 Applications\notepad++.exe_.html REG_DWORD 0x0 Applications\notepad++.exe_.json REG_DWORD 0x0 Applications\notepad++.exe_.lock REG_DWORD 0x0 Applications\notepad++.exe_.gitignore REG_DWORD 0x0 AppX4ztfk9wxr86nxmzzq47px0nh0e58b8fw_.txt REG_DWORD 0x0 Applications\notepad++.exe_.test REG_DWORD 0x0 Applications\notepad++.exe_.old REG_DWORD 0x0 Applications\notepad++.exe_.new REG_DWORD 0x0 Applications\notepad++.exe_.xml REG_DWORD 0x0 Applications\notepad++.exe_.bar REG_DWORD 0x0 Applications\notepad++.exe_.htpasswd REG_DWORD 0x0 Applications\notepad++.exe_.env REG_DWORD 0x0
Possible solution
I find out that if N++ is closed and I open the file through Windows Explorer, then language is detected and everything works, even if I open new files. If I open N++ from my taskbar shortcut (Set by right clicking an open N++ and selecting Pin to taskbar) then double click on the file in Windows Explorer is the only time it seems to not be working. Opening N++ by opening the file in my taskbar also shows a second N++ icon in that taskbar:
Unpinning the old shortcut (originally pinned so long ago I don’t recall which N++ version it was) and pinning the new one Fixed the problem entirely. It may be that enough time has passed for the problem to resolve itself like when I tried the txt and css files, so I’ll have another update tomorrow, but it appears the issue had to do with the shortcut made for an older version of N++.
-
I missed the edit window to correct this, sorry.
Before my taskbar screenshot I meant to say:
Opening N++ by opening a file in Windows Explorer also shows a a second N++ icon in my taskbar: