Notepad++的Go语言插件

huangapple go评论83阅读模式
英文:

Go language plugin for Notepad++

问题

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

我尝试了下面链接中发布的说明,但对我来说没有起作用。只是想知道是否有人成功使用过:
http://go-lang.cat-v.org/text-editors/notepad-plus-plus/

英文:

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/

答案1

得分: 43

如何在Notepad++中安装自定义语言(用户定义语言)以支持Go语言。

*编辑:更新于2018年12月26日

方法1:

  • 下载golang.udl.xml文件,然后打开Notepad++
  • 转到工具栏菜单 => 语言 => "定义你的语言..." => 导入
  • 导入golang.udl.xml文件并重新启动Notepad++

方法2是我推荐的版本,因为它可以自动高亮显示Go文件。

方法2(推荐版本):

  • 转到工具栏菜单 => 设置 => "样式配置器..."
  • 在"语言:"框中选择"C"
  • 在"**样式:"框中选择"指令词"
  • 在"用户定义关键字"框中,复制粘贴以下关键字:
  • 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
  • 然后在"**样式:"框中转到"类型词",将以下关键字复制粘贴到"用户定义关键字"框中:
  • string package import type uint uintptr uint8 uint16 uint32 uint64 int8 int16 int32 int64 float32 float64 complex complex64 complex128 byte rune iota
  • 将前景颜色样式更改为红色。
  • 重要步骤:在"**用户扩展名:"框中输入"go",然后点击"保存并关闭"按钮,然后重新启动Notepad++。
  • Notepad++的Go语言插件

“英语不是我的母语,请原谅我可能犯的任何错误。”

之所以选择方法二而不是方法一,是因为Notepad++中的UserDefinedLanguage仍然存在一些错误,NPP中的运算符和分隔符功能无法正确执行其工作。如果你不受分隔符的干扰,方法一也是不错的选择。

英文:

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++.
> Notepad++的Go语言插件

"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.

1: https://gist.github.com/blinksmith/99e5234ea601af8ba8bfab35c8fbebef "Golang udl on gist github"
2: https://i.stack.imgur.com/ORrij.png

答案2

得分: 9

是的,对我来说也没有立即生效。我没有userDefineLang.xml文件。

在完成go.xml的步骤后,

下载go.xml并将其复制到plugins\APIs\目录下。

以下是我额外做的步骤:

  1. 打开 %APPDATA%/Notepad++目录。
  2. 从链接中下载userDefineLang-Anthony.xml
  3. 将其保存到 %APPDATA%/Notepad++目录下。
  4. a) 如果存在userDefineLang.xml文件,请打开它,并将userDefineLang-Anthony.xml的内容粘贴为<NotepadPlus>的子元素。
    b) 如果没有这样的文件,请将userDefineLang-Anthony.xml重命名为userDefineLang.xml并编辑它,取消注释<!-- <NotepadPlus> --><!-- </NotepadPlus> -->
  5. 重新启动Notepad++。
  6. 打开任何.go文件。

在语言菜单中,你应该在"User Defined"之后看到一个"go"菜单项。

希望这能帮到你。

编辑:为了方便起见,我添加了我的userDefineLang.xml的内容:

<!-- begin snippet: js hide: false -->
<!-- language: lang-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; ! =&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>
<!-- end snippet -->

如果你有其他自定义语言,请小心。

英文:

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 &lt;NotepadPlus&gt;
  5. b) if no such file - Rename userDefineLang-Anthony.xml to userDefineLang.xml and edit it -> uncomment &lt;!-- &lt;NotepadPlus&gt; --&gt; and &lt;!-- &lt;/NotepadPlus&gt; --&gt;
  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

<!-- begin snippet: js hide: false -->

<!-- language: lang-xml -->

&lt;NotepadPlus&gt;
&lt;UserLang name=&quot;go&quot; ext=&quot;go&quot;&gt;
&lt;Settings&gt;
&lt;Global caseIgnored=&quot;no&quot; /&gt;
&lt;TreatAsSymbol comment=&quot;no&quot; commentLine=&quot;no&quot; /&gt;
&lt;Prefix words1=&quot;no&quot; words2=&quot;no&quot; words3=&quot;no&quot; words4=&quot;no&quot; /&gt;
&lt;/Settings&gt;
&lt;KeywordLists&gt;
&lt;Keywords name=&quot;Delimiters&quot;&gt;&amp;quot;`0&amp;quot;`&lt;/Keywords&gt;
&lt;Keywords name=&quot;Folder+&quot;&gt;&lt;/Keywords&gt;
&lt;Keywords name=&quot;Folder-&quot;&gt;&lt;/Keywords&gt;
&lt;Keywords name=&quot;Operators&quot;&gt;( ) [ ] { } ... . , _ &amp;amp; ^ %  &amp;gt; &amp;lt; ! =&lt;/Keywords&gt;
&lt;Keywords name=&quot;Comment&quot;&gt; 1/* 2*/ 0//&lt;/Keywords&gt;
&lt;Keywords name=&quot;Words1&quot;&gt;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&lt;/Keywords&gt;
&lt;Keywords name=&quot;Words2&quot;&gt;&lt;/Keywords&gt;
&lt;Keywords name=&quot;Words3&quot;&gt;&lt;/Keywords&gt;
&lt;Keywords name=&quot;Words4&quot;&gt;&lt;/Keywords&gt;
&lt;/KeywordLists&gt;
&lt;Styles&gt;
&lt;WordsStyle name=&quot;DEFAULT&quot; styleID=&quot;11&quot; fgColor=&quot;000000&quot; bgColor=&quot;FFFFFF&quot; fontName=&quot;&quot; fontStyle=&quot;0&quot; /&gt;
&lt;WordsStyle name=&quot;FOLDEROPEN&quot; styleID=&quot;12&quot; fgColor=&quot;FFFF00&quot; bgColor=&quot;FFFFFF&quot; fontName=&quot;&quot; fontStyle=&quot;0&quot; /&gt;
&lt;WordsStyle name=&quot;FOLDERCLOSE&quot; styleID=&quot;13&quot; fgColor=&quot;0B243B&quot; bgColor=&quot;FFFFFF&quot; fontName=&quot;&quot; fontStyle=&quot;0&quot; /&gt;
&lt;WordsStyle name=&quot;KEYWORD1&quot; styleID=&quot;5&quot; fgColor=&quot;AA0000&quot; bgColor=&quot;FFFFFF&quot; fontName=&quot;&quot; fontStyle=&quot;1&quot; /&gt;
&lt;WordsStyle name=&quot;KEYWORD2&quot; styleID=&quot;6&quot; fgColor=&quot;AA0000&quot; bgColor=&quot;FFFFFF&quot; fontName=&quot;&quot; fontStyle=&quot;1&quot; /&gt;
&lt;WordsStyle name=&quot;KEYWORD3&quot; styleID=&quot;7&quot; fgColor=&quot;AA0000&quot; bgColor=&quot;FFFFFF&quot; fontName=&quot;&quot; fontStyle=&quot;0&quot; /&gt;
&lt;WordsStyle name=&quot;KEYWORD4&quot; styleID=&quot;8&quot; fgColor=&quot;A00000&quot; bgColor=&quot;FFFFFF&quot; fontName=&quot;&quot; fontStyle=&quot;0&quot; /&gt;
&lt;WordsStyle name=&quot;COMMENT&quot; styleID=&quot;1&quot; fgColor=&quot;AAAAAA&quot; bgColor=&quot;FFFFFF&quot; fontName=&quot;&quot; fontStyle=&quot;0&quot; /&gt;
&lt;WordsStyle name=&quot;COMMENT LINE&quot; styleID=&quot;2&quot; fgColor=&quot;AAAAAA&quot; bgColor=&quot;FFFFFF&quot; fontName=&quot;&quot; fontStyle=&quot;0&quot; /&gt;
&lt;WordsStyle name=&quot;NUMBER&quot; styleID=&quot;4&quot; fgColor=&quot;A52A2A&quot; bgColor=&quot;FFFFFF&quot; fontName=&quot;&quot; fontStyle=&quot;0&quot; /&gt;
&lt;WordsStyle name=&quot;OPERATOR&quot; styleID=&quot;10&quot; fgColor=&quot;8000FF&quot; bgColor=&quot;FFFFFF&quot; fontName=&quot;&quot; fontStyle=&quot;1&quot; /&gt;
&lt;WordsStyle name=&quot;DELIMINER1&quot; styleID=&quot;14&quot; fgColor=&quot;0000FF&quot; bgColor=&quot;FFFFFF&quot; fontName=&quot;&quot; fontStyle=&quot;0&quot; /&gt;
&lt;WordsStyle name=&quot;DELIMINER2&quot; styleID=&quot;15&quot; fgColor=&quot;0000FF&quot; bgColor=&quot;FFFFFF&quot; fontName=&quot;&quot; fontStyle=&quot;0&quot; /&gt;
&lt;WordsStyle name=&quot;DELIMINER3&quot; styleID=&quot;16&quot; fgColor=&quot;0000FF&quot; bgColor=&quot;FFFFFF&quot; fontName=&quot;&quot; fontStyle=&quot;0&quot; /&gt;
&lt;/Styles&gt;
&lt;/UserLang&gt;
&lt;/NotepadPlus&gt;

<!-- end snippet -->

Be careful if you have other user defined languages there.

huangapple
  • 本文由 发表于 2015年1月3日 03:24:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/27747457.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定