MIB file (SNMP) syntax highlighting [User Defined Language]



  • I work on a lot of SNMP projects where I need to read MIB files. I could not find a UDL for MIB files anywhere on the net, but I found a few forum posts here and there where people request it. In the end I decided to make one for personal use, and figured i might as well share it.

    Download here: pastebin.com (save as i.e. userDefineLang-MIB.xml, and place in directory .\Notepad++\userDefineLangs)

    2019-10-16 08_21_03-HOST-RESOURCES-MIB-rfc2790.txt - Notepad++.png

    It’s very rough around the edges, and does not do folding (I could not get it to work due to the complexity of delimiters in ASN.1). It’s purely for visual syntax highlighting to ease on-screen reading of MIB files.



  • wonderful :) I was looking for MIB/SNMP compatibility today :)

    But the BackColor is not working associated to DarkTheme :
    [https://github.com/Ludomancer/VS2015-Dark-Npp](link url)



  • @Vincent-Duvernet said in MIB file (SNMP) syntax highlighting [User Defined Language]:

    But the BackColor is not working associated to DarkTheme

    User Defined Languages do not honor themes: if you change your theme, it does not change the coloring for the UDL syntax highlighter. You can use Language > User Defined Language > Define Your Language… to change the colors for your specific UDL.



  • @Vincent-Duvernet said in MIB file (SNMP) syntax highlighting [User Defined Language]:

    wonderful :) I was looking for MIB/SNMP compatibility today :)

    Why use a UDL? The default theme already has ASN.1 and that can be copied into (and adjusted for color) into your preferred theme (as @PeterJones mentions). I did this for Obsidian Theme which I use exclusively.

    You may need to associate your MIB extension with ASN.1 for Notepad++ to recognize the file on opening:

    Settings => Style Configurator… =>

    3540c3c6-4fb9-4c15-a9c3-dccd5f2c4d6e-image.png

    Cheers.



  • @Vincent-Duvernet said in MIB file (SNMP) syntax highlighting [User Defined Language]:

    wonderful :) I was looking for MIB/SNMP compatibility today :)

    You may also want it in the function list. I’ve added in my $(NPP_INSTALL_DIR)/functionList.xml file:

     <association id="asn1_syntax" langID="65"  />
    

    […] then down in the parsers section:

    <!-- ============== [ ASN.1 ] -->
    
    <parser
    	displayName="ASN.1"
    	id         ="asn1_syntax"
    	commentExpr="(?x)
    					(?m-s:\-\-.*$)    # Single Line Comment
    				"
    >
    
    	<classRange mainExpr="(?:^\s*\w+\s+::=\s+[\w-]+\s*)">
    		<className>
    			<nameExpr expr="(?:\s*)\K[\w]+"/>
    		</className>
    		<function
    			mainExpr="(?:^\s*\w+\s+)">
    			<functionName>
    				<funcNameExpr expr="(?:\s*)\K[\w]+"/>
    			</functionName>
    		</function>
    	</classRange>
    	<function
    		mainExpr="(?:^\s*\w+\s+OBJECT-\w+[\n\s]*)">
    		<functionName>
    			<nameExpr expr="(?:\s*)\K[\w]+"/>
    		</functionName>
    	</function>
    </parser>
    

    Cheers.


Log in to reply