Pages

Thursday, September 16, 2010

Go language syntax highlighting for Notepad++

Save the code below as go.lang.xml

<NotepadPlus>
    <UserLang name="go" ext="go">
        <Settings>
            <Global caseIgnored="no" escapeChar="\" />
            <TreatAsSymbol comment="yes" commentLine="yes" />
            <Prefix words1="no" words2="no" words3="no" words4="no" />
        </Settings>
        <KeywordLists>
            <Keywords name="Delimiters">&quot;&apos;0&quot;&apos;0</Keywords>
            <Keywords name="Folder+">{</Keywords>
            <Keywords name="Folder-">}</Keywords>
            <Keywords name="Operators">- ! % &amp; ( ) * . : ? ^ | ~ + &lt; = &gt;</Keywords>
            <Keywords name="Comment">1/* 2*/ 0//</Keywords>
            <Keywords name="Words1">const func struct type var chan defer break case const continue default else fallthrough for go goto if return switch export extends final goto implements import interface package range select static volatile</Keywords>
            <Keywords name="Words2">nil true false boolean byte char enum float int int32 int64 uint uint32 uint64 string</Keywords>
            <Keywords name="Words3"></Keywords>
            <Keywords name="Words4"></Keywords>
        </KeywordLists>
        <Styles>
            <WordsStyle name="DEFAULT" styleID="11" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
            <WordsStyle name="FOLDEROPEN" styleID="12" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="1" />
            <WordsStyle name="FOLDERCLOSE" styleID="13" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="1" />
            <WordsStyle name="KEYWORD1" styleID="5" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" />
            <WordsStyle name="KEYWORD2" styleID="6" fgColor="0080FF" bgColor="FFFFFF" fontName="" fontStyle="0" />
            <WordsStyle name="KEYWORD3" styleID="7" fgColor="004000" bgColor="FFFFFF" fontName="" fontStyle="1" />
            <WordsStyle name="KEYWORD4" styleID="8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
            <WordsStyle name="COMMENT" styleID="1" fgColor="C0C0C0" bgColor="FFFFFF" fontName="" fontStyle="0" />
            <WordsStyle name="COMMENT LINE" styleID="2" fgColor="C0C0C0" bgColor="FFFFFF" fontName="" fontStyle="0" />
            <WordsStyle name="NUMBER" styleID="4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
            <WordsStyle name="OPERATOR" styleID="10" fgColor="808000" bgColor="FFFFFF" fontName="" fontStyle="0" />
            <WordsStyle name="DELIMINER1" styleID="14" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="1" />
            <WordsStyle name="DELIMINER2" styleID="15" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="1" />
            <WordsStyle name="DELIMINER3" styleID="16" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
        </Styles>
    </UserLang>
</NotepadPlus>

Open Notepad++ View -> User Define Dialog and now import go.lang.xml. Now go to Settings -> Preferences -> File Association, click on customize and add go. Close Notepad++ and open it again to see the effect.


Refer: http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=User_Defined_Languages
http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=User_Defined_Language_Files

3 comments:

Cesar Sanz said...

Thanks.. It worked!

Matthew Ferrin said...

Open go.lang.xml, delete float, and replace it with float64 and float32 beforehand. Looks like I should have changed boolean to bool as well. I'm finding that some of the keywords are wrong, but modifications are simple. View -> User Define Dialog -> User Language -> go -> Remove ... will allow you to start fresh between edits and imports.

Matthew Ferrin said...

Language -> Define your language...
Allowed easy fixes. Thanks! just got it going on my new computer.

Post a Comment

 
Powered by NishantSoft