FAQ Desk: To Add Extensions Automatically or Not To Add Extensions Automatically



  • Hello, and welcome to the FAQ Desk.

    You have been directed here because you have asked a question about automatically adding extensions or a related subject: perhaps something like “How do I always save my text files with .txt extension?”

    As described in the official documents, there is a setting Settings > Preferences > Default Directory > ☐ Use new style dialog (without file extension feature & Unix style path capacity):

    If you want to have the extension auto-applied, you have to disable this option.

    Details

    The Microsoft Windows API allows for two styles of open/save dialogs (derived from the docs):

    • “old style” has “Quick Access”, “Desktop”, and others as icon-buttons along the left; it will auto-apply the selected file-type’s extension to the file (so typing a filename of blah when a file type of “Normal text file (.txt)” is selected will save blah.txt); it will also allow using Unix-style backslashes as a path separator, rather than Windows-style forward slashes.
    • “new style” does not have the icon-buttons (instead, Windows presents those in the tree, similar to other drives and folders); even when a file-type is selected, the user is required to specify the desired file extension (thus the file-type selector is primarily for filtering what existing files are listed in the directory listing); and it will not understand Unix-style backslashes as path separators.

    Warning

    If you are using the old-style dialog, be wary of that “feature” from Windows… because whatever happens to come first in the list of extensions for a given dropdown is what Windows will apply; hence, if you type blah and apply c++ source file, there’s a good chance that you’ll save blah.h rather than blah.cpp, which is probably not what you want.

    Note that Microsoft Windows introduced the “new style” dialogs with Windows Vista in 2006, and Windows XP was thus the last time that Microsoft recommended the “old style”.

    I always use the new-style, because the old-style was obsoleted by Windows’s new-style dialog many versions of Windows ago (and could theoretically be eliminated from the Windows codebase in the future, at which point this option will cease to work in Notepad++), and (more importantly) because the new-style encourages you to take control of your destiny by controlling extension yourself rather than relying on Windows to fill in the extension for you, and (most importantly to me) because it enables the tree-view to the left rather than just having the four or five icons for windows-preferred locations, and making it more clicks to find the location you want.

    You are allowed to use the “old style” if that’s what you want, but please be aware of the risks.


Log in to reply