doujilou3903
2015-01-02 19:24
浏览 270
已采纳

Notepad ++的Go语言插件

Did someone try using golang (Go programming language) plugin for Notepad++?

I tried the instructions published at the below link, but it did not work for me. Just wondering if it worked for anyone:
http://go-lang.cat-v.org/text-editors/notepad-plus-plus/

图片转代码服务由CSDN问答提供 功能建议

有人尝试为Notepad ++使用 golang (Go编程语言)插件吗?

我尝试了以下链接中发布的说明,但对我而言不起作用。 只是想知道它是否对任何人都有效:
http://go-lang.cat-v.org/text-editors/notepad-plus-plus/

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dpnru86024 2016-03-31 09:47
    已采纳

    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++. enter image description here
    "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.

    打赏 评论
  • dtufl26404 2015-01-02 20:19

    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:

    1. Open %APPDATA%/Notepad++
    2. Download userDefineLang-Anthony.xml from their link
    3. Save it to %APPDATA%/Notepad++
    4. a) if there is file userDefineLang.xml there - open it and paste the content of userDefineLang-Anthony.xml as child of <NotepadPlus>
    5. b) if no such file - Rename userDefineLang-Anthony.xml to userDefineLang.xml and edit it -> uncomment <!-- <NotepadPlus> --> and <!-- </NotepadPlus> -->
    6. Restart Notepad++
    7. 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">&quot;`0&quot;`</Keywords>
                <Keywords name="Folder+"></Keywords>
                <Keywords name="Folder-"></Keywords>
                <Keywords name="Operators">( ) [ ] { } ... . , _ &amp; ^ %  &gt; &lt; ! =</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.

    打赏 评论

相关推荐 更多相似问题