When I go to open files in NPP, the file types defaults to "all types (.)".
How can I make this default to ".txt"?
It may be a windows thing, since I'm sure it just uses the default windows file open dialog, but other programs (textpad, notepad) are able to default it.
Best Answer
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 theNppIO.cpp
file). Initially, theAll Types, *.*
filter is added to the filter list, and then, theint 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 passedFileDialog
's filter list. The code inFileOpen
looks like this:You can change the default filter index. To do that, you can instead change those lines to this:
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: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.