File Associations

From Notepad++ Wiki
Jump to: navigation, search
How to have certain files types opened by Notepad++?


Associating a file type with Notepad++

A file-type association is how Windows knows which program to use to open a file with a particular extension, such as .TXT or .CPP.

The standard way to go would be to go to your favorite file manager application - some call it Explorer -, going to the File Types dialog and entering a full command line to associate the file extension with Notepad++. There is a more straightforward way though, using the Settings -> Preferences -> File Associations tab.

This tab has three lists.

  • The rightmost one, "Registered exts," contains all extensions associated with Notepad++.
  • The middle list is an incomplete list of extensions that are not associated with Notepad++.
  • The leftmost list, "Supported exts," names various sets of file types, which you may want to consistently associate (or so the developer thought).

On either side of the Registered list are "arrow" buttons which are used to change associations.

Selecting an entry in the Supported list, other than "custom", causes the middle list to be populated with the unregistered extensions for that list; this is a convenience, it does not change the associations. At this point, you may select an extension (one at a time) in the middle list and click the adjacent "arrow" button; this moves the extensions from the Unregistered list to the Registered list.

Selecting the "custom" entry in the Supported list causes the middle list to change to an edit field. Type the desired extension (including the '.') and click the "arrow" button to create an association.

To unregister an extension, choose it from the registered list and click the "arrow" button to the left, which points to a trashcan icon:

  • Predefined extensions are recycled and become available again on the middle list the next time the corresponding category is selected on the left.
  • Custom extensions are not recycled, and you cannot define new categories as of v6.6.6.

Drawbacks and workarounds

Notepad++ lumps all associated files as "Notepad++ document". This is good, but loses original extensions and icons, which one might still have use for. The following link to a helper application was posted on Open Discussion Forum: http://aaron.sherber.com/files/npp-assoc.zip

What the app does corresponds to the following .inf file, also posted on Help. Transcript follows; you can adapt for your own file types:

RE: File Association in Windows By: Anakondrak (anakondrak) - 2009-06-09 14:46

I had the same problem as you. I don't know if there is a quick way to solve this but anyway, here is how I solved it. Basically what you need to do is to create new entries in the registry for the different file types and then you associate these files with the new values.

Run regedit, export HKEY_CLASSES_ROOT\Notepad++_file and edit the .reg file according to your preferences. See the example below.

This was the original .reg file Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Notepad++_file] @="Notepad++ Document" "EditFlags"=hex:00,00,00,00

[HKEY_CLASSES_ROOT\Notepad++_file\DefaultIcon] @="\"C:\\Program Files\\Notepad++\\notepad++.exe\",0"

[HKEY_CLASSES_ROOT\Notepad++_file\shell]

[HKEY_CLASSES_ROOT\Notepad++_file\shell\Edit] @="&Edit"

[HKEY_CLASSES_ROOT\Notepad++_file\shell\Edit\command] @="\"C:\\Program Files\\Microsoft Office\\Office12\\msohtmed.exe\" %1"

[HKEY_CLASSES_ROOT\Notepad++_file\shell\open]

[HKEY_CLASSES_ROOT\Notepad++_file\shell\open\command] @="\"C:\\Program Files\\Notepad++\\notepad++.exe\" \"%1\""

[HKEY_CLASSES_ROOT\Notepad++_file\shell\Print] @="&Print"

[HKEY_CLASSES_ROOT\Notepad++_file\shell\Print\command] @="\"C:\\Program Files\\Microsoft Office\\Office12\\msohtmed.exe\" /p %1"

[HKEY_CLASSES_ROOT\Notepad++_file\ShellEx]

[HKEY_CLASSES_ROOT\Notepad++_file\ShellEx\IconHandler] @="{42042206-2D85-11D3-8CFF-005004838597}"

I replaced "Notepad++_file" with "Notepad++_php" and "Notepad++ Document" with "PHP". The new file looked like this:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Notepad++_php] @="PHP" "EditFlags"=hex:00,00,00,00

[HKEY_CLASSES_ROOT\Notepad++_php\DefaultIcon] @="\"C:\\Program Files\\Notepad++\\notepad++.exe\",0"

[HKEY_CLASSES_ROOT\Notepad++_php\shell]

[HKEY_CLASSES_ROOT\Notepad++_php\shell\Edit] @="&Edit"

[HKEY_CLASSES_ROOT\Notepad++_php\shell\Edit\command] @="\"C:\\Program Files\\Microsoft Office\\Office12\\msohtmed.exe\" %1"

[HKEY_CLASSES_ROOT\Notepad++_php\shell\open]

[HKEY_CLASSES_ROOT\Notepad++_php\shell\open\command] @="\"C:\\Program Files\\Notepad++\\notepad++.exe\" \"%1\""

[HKEY_CLASSES_ROOT\Notepad++_php\shell\Print] @="&Print"

[HKEY_CLASSES_ROOT\Notepad++_php\shell\Print\command] @="\"C:\\Program Files\\Microsoft Office\\Office12\\msohtmed.exe\" /p %1"

[HKEY_CLASSES_ROOT\Notepad++_php\ShellEx]

[HKEY_CLASSES_ROOT\Notepad++_php\ShellEx\IconHandler] @="{42042206-2D85-11D3-8CFF-005004838597}"

I then merged the new file into the registry. After the merge I had 2 keys in the registry, the original one ([HKEY_CLASSES_ROOT\Notepad++_file]) and the new one ([HKEY_CLASSES_ROOT\Notepad++_php]).

The next step was to associate the .php files with the new file type that I had created. I used a freeware application named FileTypesMan which can be downloaded from this location: http://www.nirsoft.net/utils/file_types_manager.html