Go language plugin for Notepad++
How to install user defined language Notepad++ for golang.
*EDIT: UPDATED in 26/12/2018
Method 1 :
- Download golang.udl.xml on gist github and then open Notepad++
- Go to Toolbar Menu => Language -> "Define your language..." -> Import.
- Import golang.udl.xml and restart Notepad++.
and method 2 is my recommended version because it's automatically highlighting go files.
Method 2 (Recommended Version) :
- Go to Toolbar Menu => Settings -> "Style Configurator...".
- in "Language :" box choose "C"
- in "Style :" box choose "INSTRUCTION WORD"
- in "User-defined-keywords" box, copy paste the keywords below.
var func append utf8 nil cap close closed copy image len make new panic print println range real recover select chan defer go interface map range true false
- then in "Style :" box go to"TYPE WORD", copy paste the keywords below to "User-defined-keywords" box.
string package import type uint uintptr uint8 uint16 uint32 uint64 int8 int16 int32 int64 float32 float64 complex complex64 complex128 byte rune iota
- Change Foreground colour style to RED.
- IMPORTANT STEP: in "User-ext. :" box type "go". and click "Save & Close" button, then restart Notepad++.
"English is not my mother tongue; please excuse any errors on my part."
the reason why choosing method two rather than method one is because UserDefinedLanguage in Notepad++ still having a bugs, Operators & Delimiters feature in NPP cannot correctly do their job. if you are not disturbed by the delimiter then method one is quite good.
Yep, it did not work out of the box for me too. I did not have userDefineLang.xml
After finishing the step for go.xml,
Download go.xml and copy it to plugins\APIs.
this is what I did extra:
- Open
%APPDATA%/Notepad++
- Download userDefineLang-Anthony.xml from their link
- Save it to
%APPDATA%/Notepad++
- a) if there is file userDefineLang.xml there - open it and paste the content of userDefineLang-Anthony.xml as child of
<NotepadPlus>
- b) if no such file - Rename userDefineLang-Anthony.xml to userDefineLang.xml and edit it -> uncomment
<!-- <NotepadPlus> -->
and<!-- </NotepadPlus> -->
- Restart Notepad++
- Open any .go file
You should see in Language menu - after the User Defined. a "go" menu item.
I hope this helps.
EDIT: to make it easy I'm adding the content of my userDefineLang.xml
<NotepadPlus>
<UserLang name="go" ext="go">
<Settings>
<Global caseIgnored="no" />
<TreatAsSymbol comment="no" commentLine="no" />
<Prefix words1="no" words2="no" words3="no" words4="no" />
</Settings>
<KeywordLists>
<Keywords name="Delimiters">"`0"`</Keywords>
<Keywords name="Folder+"></Keywords>
<Keywords name="Folder-"></Keywords>
<Keywords name="Operators">( ) [ ] { } ... . , _ & ^ % > < ! =</Keywords>
<Keywords name="Comment"> 1/* 2*/ 0//</Keywords>
<Keywords name="Words1">append bool break byte cap case chan close closed complex complex128 complex64 const continue copy default defer else fallthrough false float32 float64 for func go goto if iota imag import int int16 int32 int64 int8 interface len make map new nil package panic print println range real recover return select string struct switch true type uint uint16 uint32 uint64 uint8 uintptr var</Keywords>
<Keywords name="Words2"></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="FFFF00" bgColor="FFFFFF" fontName="" fontStyle="0" />
<WordsStyle name="FOLDERCLOSE" styleID="13" fgColor="0B243B" bgColor="FFFFFF" fontName="" fontStyle="0" />
<WordsStyle name="KEYWORD1" styleID="5" fgColor="AA0000" bgColor="FFFFFF" fontName="" fontStyle="1" />
<WordsStyle name="KEYWORD2" styleID="6" fgColor="AA0000" bgColor="FFFFFF" fontName="" fontStyle="1" />
<WordsStyle name="KEYWORD3" styleID="7" fgColor="AA0000" bgColor="FFFFFF" fontName="" fontStyle="0" />
<WordsStyle name="KEYWORD4" styleID="8" fgColor="A00000" bgColor="FFFFFF" fontName="" fontStyle="0" />
<WordsStyle name="COMMENT" styleID="1" fgColor="AAAAAA" bgColor="FFFFFF" fontName="" fontStyle="0" />
<WordsStyle name="COMMENT LINE" styleID="2" fgColor="AAAAAA" bgColor="FFFFFF" fontName="" fontStyle="0" />
<WordsStyle name="NUMBER" styleID="4" fgColor="A52A2A" bgColor="FFFFFF" fontName="" fontStyle="0" />
<WordsStyle name="OPERATOR" styleID="10" fgColor="8000FF" bgColor="FFFFFF" fontName="" fontStyle="1" />
<WordsStyle name="DELIMINER1" styleID="14" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" />
<WordsStyle name="DELIMINER2" styleID="15" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" />
<WordsStyle name="DELIMINER3" styleID="16" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" />
</Styles>
</UserLang>
</NotepadPlus>
Be careful if you have other user defined languages there.