Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
It's certainly possible for a programmer to code, but there is no way to change the setting once its there. –  soandos Aug 3 '11 at 16:59

3 Answers 3

up vote 4 down vote accepted

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.

share|improve this answer
    
well, it's for a programmer. do you have an way to change it directly on binaries (in a manual, editing with hex editor, or in a automatic way, applying a patch) or some modified release that has this modification? –  kokbira Aug 3 '11 at 18:21
    
I just tried to hex-edit the binary, but since the initial filter is only defined as .*, I can't insert any additional characters (I can, however, change the existing characters). I'll look more into this, but as of now, I think it would be easier to re-compile it. –  Breakthrough Aug 3 '11 at 19:01

It's certainly possible for a programmer to code, but there is no way to change the setting once its there.Sorry.

share|improve this answer
1  
NPP is open source. You could always make the change yourself and recompile! –  Andrew Lambert Aug 3 '11 at 17:08
    
at that point its a coding problem, and not for SU. –  soandos Aug 3 '11 at 17:19
    
I could, it's probably a trivial fix (even if it would take a little bit to find it.) Of course, I wouldn't be guaranteed my plugins would still work the way I want them to, and would be a bit of a roundabout way to do something there's a chance is actually already exposed as a setting somehow. –  corsiKa Aug 3 '11 at 17:21
1  
I would argue that you could implement it as a feature (you just change the value of the filter index), but as it stands, it isn't one. That being said, if you want to know how to change it, let me know and I will post it as an answer. If you did make the change and recompile it yourself, your plugins would all still work just fine (and compiling NPP is easy since there's no additional dependencies, it's all C++ with STL). –  Breakthrough Aug 3 '11 at 17:30
1  
@TotalFrickinRockstarFromMars - it's unlikely to break any plugin. All they are doing is calling the Common File Dialog in Win32. The txt extension is already there, so it's just a matter of setting the index number. –  surfasb Aug 3 '11 at 18:50

By default you cannot change that "feature" in a normal way.

One solution is to change the program binaries, doing some code changes (if the code is open and you are licensed to do it) and recompile it to generate a different program binary or to "hack" the binary changing some files with an hex editor or a already created patch. Another solution is to change default Windows file dialogs in some way.

You can try that software, that should use the second solution: File-Ex

With that, you can add some features to open and save dialogs and remember the chosen filter. Try that and post if it functioned for you.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.