Friday, June 24, 2011

DevTnT v2.1 – Notepad++: Map file extension to language

You might find it useful, to open files of your .NET-solution directly from Windows Explorer without launching Visual Studio. For that purpose, Notepad++ is a perfect choice.

Besides other goodness, Notepad++ provides syntax highlighting. But for that to work properly, Notepad++ must know the language of the file’s content. Especially there are several files in an XML format that do have a file extension other than xml. The best example may be project files (*.csproj, *.vbproj). Other examples are the extensions xaml, config, wsdl, etc. For those files, it may be cumbersome to tell Notepad++ after opening the file, what language the file content is.

Fortunately, the mappings of file extensions to languages can be configured in the file langs.xml, found in %AppData%\Notepad++. That file has a Language-element for each language along with a ext attribute. That ext-attribute lists all file extensions that Notepad++ recognizes for the respective language.

Mine looks like this:

Language name="xml" ext="xml xsml xsl xsd kml wsdl config vdf csproj targets xaml"

After relaunching Notepad++, it automatically chooses the language of a newly opened file according to that mapping.

Tip: For a selection of file editors (including Notepad++), see this post.

No comments:

Post a Comment