Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I override a default file extension for Notepad++?

I want to open iOS objective-c files in Notepad++ (with a .m extension) and have it designated as an Objective-C file. In settings --> style configurator, I know that I can add a "user ext." (m) for Objective-C. The problem is that Matlab already uses the .m extension as the default extension field, which can't be edited. Is there a file I can access to change this?

like image 637
Roy Avatar asked Aug 12 '11 16:08

Roy


1 Answers

Notepad++ doesn't list .h, .m and .mm files as Objective-C files (.mm is Objective-C++) by default for some reason.

You can modify your langs.xml file to tell Notepad++ to associate those extensions with Objective-C. Open the file %AppData%\Notepad++\langs.xml, and scroll down to the following area:

<Language name="objc" ext="" commentLine="//" commentStart="/*" commentEnd="*/">
    <Keywords name="instre1">if else switch case default break goto return for while do continue typedef sizeof NULL self super nil NIL</Keywords>
    <Keywords name="instre2">interface implementation protocol end private protected public class selector encode defs</Keywords>
    <Keywords name="type1">void struct union enum char short int long double float signed unsigned const static extern auto register volatile id Class SEL IMP BOOL</Keywords>
    <Keywords name="type2">oneway in out inout bycopy byref</Keywords>
</Language>

Then add h m mm to the ext attribute:

<Language name="objc" ext="h m mm" commentLine="//" commentStart="/*" commentEnd="*/">
    <Keywords name="instre1">if else switch case default break goto return for while do continue typedef sizeof NULL self super nil NIL</Keywords>
    <Keywords name="instre2">interface implementation protocol end private protected public class selector encode defs</Keywords>
    <Keywords name="type1">void struct union enum char short int long double float signed unsigned const static extern auto register volatile id Class SEL IMP BOOL</Keywords>
    <Keywords name="type2">oneway in out inout bycopy byref</Keywords>
</Language>

Then restart Notepad++.

If editing the langs.xml file in your %AppData%\Notepad++ folder doesn't work, you'll have to open the one in %ProgramFiles%\Notepad++ instead. Make sure to back up the original in case you mess up somewhere.

like image 90
BoltClock Avatar answered Nov 14 '22 21:11

BoltClock