I have just finished reviewing the NPP source code, and have some additional details if you would like to seek a solution for yourself. When you go File -> Open, the list of file extensions is loaded from the Scintilla (SciLexer.dll) file.
Now, when you go File -> Open, the void Notepad_plus::fileOpen()
function is called (in the NppIO.cpp
file). Initially, the All Types, *.*
filter is added to the filter list, and then, the int Notepad_plus::setFileOpenSaveDlgFilters(FileDialog & fDlg, int langType)
function is called (in the same file). This function goes through the Scintilla entries I mentioned above, and adds them to the passed FileDialog
's filter list. The code in FileOpen
looks like this:
fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL);
setFileOpenSaveDlgFilters(fDlg);
You can change the default filter index. To do that, you can instead change those lines to this:
fDlg._ofn.nFilterIndex = 2L;
fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL);
setFileOpenSaveDlgFilters(fDlg);
That should set the filter index to the second one by default.
Another easy way to quick-fix this is to modify those lines (again, in NppIO.cpp
) to look like this:
fDlg.setExtFilter(TEXT("Text files"), TEXT(".txt"),
TEXT("All types"), TEXT(".*"), NULL);
setFileOpenSaveDlgFilters(fDlg);
That will ensure that Text files are the first filter on the list. Do note that this will cause the .txt extension to be double-defined in the entries, but if you can live with that caveat, this should work fine.
Best Answer
Run it from the command-line as such:
Or from the menu: Language, N, Normal Text.
That's lower-case L in "
-ltext
" by the way.Update: To make it work by double-clicking on the file in Windows Explorer, put the above in a batch file as such (call the file, say,
C:\OpenTxt.bat
):Then in Windows Explorer, right-click on any .txt file, choose
Open With
thenChoose default program
,Browse
, choose yourC:\OpenTxt.bat
and check Always use the selected program to open this kind of file. Then OK.