在Notepad++中添加一个用户定义的语言

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

Adding a user-defined language in Notepad++

问题

我正在尝试在Notepad++中为Go编程语言添加语法插件。

有一个用于这种“用户定义”语言的存储库。我下载并解压缩了Go文件,其中包含一个README、一个userDefinedLang_Go.xml和一个go.xml。

我尝试按照页面底部的说明进行操作。由于我使用的是Windows 7 (x64),我的Notepad++目录是“C:\Program Files (x86)\Notepad++”。

由于以前没有安装过用户定义的语言,所以我没有一个userDefinedLang.xml文件,所以我将userDefinedLang_Go.xml复制到根目录,并将其重命名为userDefinedLang.xml。

然后,我将go.xml复制到C:\Program Files (x86)\Notepad++\plugins\APIs\。

这似乎是所有必要的步骤。然而,当我打开Notepad++时,在“Lang => User Defined”附近没有“Go”,而且*.go*文件上没有语法着色。尝试通过“View => User-Defined Dialogue => import”导入时出现“导入失败”的错误。

我做错了什么?我使用的是干净的Notepad++安装版本6.1.8。

英文:

I'm trying to add the syntax plugin for the Go programming language in Notepad++.

There is a repository for such user-defined languages. I downloaded and unzipped the Go files, which contained a README, a userDefinedLang_Go.xml, and go.xml.

I attempted to follow the instructions at the bottom of the page as follows. Since I am using Windows 7 (x64), my Notepad++ directory is "C:\Program Files (x86)\Notepad++".

Having not installed a user defined language before, I didn't have a userDefinedLang.xml file already, so I copied userDefinedLang_Go.xml into the root directory, and renamed it to remove the "_Go", making it userDefinedLang.xml.

I then copied go.xml into C:\Program Files (x86)\Notepad++\plugins\APIs\

This seems to be all of the steps necessary. However, when I open Notepad++, there is no "Go" near "Lang => User Defined", and there is no syntactic coloring on a .go file. Attempting to import via "View => User-Defined Dialogue => import" gives a "fail to import" error.

What am I doing wrong? I'm using a clean installation of Notepad++, which is version 6.1.8.

答案1

得分: 56

我必须将我的userDefineLang.xml文件放在我的AppData\Roaming文件夹中:

C:\Users\[user]\AppData\Roaming\Notepad++
英文:

I had to put my userDefineLang.xml file in my AppData\Roaming folder:

C:\Users\[user]\AppData\Roaming\Notepad++

答案2

得分: 17

新安装的Notepad++ 6.4.5在Windows 7 64位上

从Notepad++网站下载:

http://docs.notepad-plus-plus.org/index.php?title=User_Defined_Language_Files#G

将"go.xml"复制到C:\Program Files (x86)\Notepad++\plugins\APIs

默认安装没有任何用户定义的语言,所以你可以这样做:

  • 将"userDefineLang_Go.xml"复制到C:\Users<USER>\AppData\Roaming\Notepad++
  • 从文件名中删除"_Go",使其变为"userDefineLang.xml"
  • 取消注释打开和关闭的"NotepadPlus"标签。

(如果你已经有一个userDefineLang.xml文件,则将内容添加到_Go文件中。)

重新启动Notepad++。

英文:

New install of Notepad++ 6.4.5 on Windows&nbsp;7 64 bit

Download from Notepad++ site:

http://docs.notepad-plus-plus.org/index.php?title=User_Defined_Language_Files#G

Copy "go.xml" to C:\Program Files (x86)\Notepad++\plugins\APIs.

The default install doesn't have any user-defined languages, so you can do this:

  • Copy "userDefineLang_Go.xml" to C:\Users&lt;USER>\AppData\Roaming\Notepad++
  • Remove the "_Go" from the file name, so it's "userDefineLang.xml"
  • Uncomment the opening and closing "NotepadPlus" tags.

(If you already have a userDefineLang.xml then add the content from the _Go file.)

Restart Notepad++.

答案3

得分: 8

我在一些调试后,终于在我的系统上使其工作了。将以下内容放在userDefinedLang.xml文件和go.xml文件的顶部:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;Windows-1252&quot; ?&gt;

这样应该就可以了(重新打开Notepad++后)。

go.xml应该放在plugins/APIs文件夹中,而userDefinedLang.xml应该放在Notepad++的根目录中,就像你说的那样。

英文:

I just got it working on my system after some tinkering. Put this at the top of the userDefinedLang.xml file and the go.xml file:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;Windows-1252&quot; ?&gt;

That should do the trick (after reopening Notepad++).

go.xml should be in the plugins/APIs folder, and userDefinedLang.xml goes in the root of Notepad++ as you said.

答案4

得分: 4

一些其他答案没有讨论的事情:一些旧版本的Notepad++似乎与这些答案中的任何一个都不兼容。

在将Notepad++升级到6.4.2版本之前,我尝试了几乎所有的解决方案。

xkcd 979

已测试的Notepad++版本:

  • 5.9 - 不可用 - 由namey测试
  • 6.4.2 - 可用 - 由Elysian Fields测试
  • 6.6.9 - 可用 - 由namey测试

对于其他版本,可能会有所不同。

英文:

Something other answers do not discuss: Some older versions of Notepad++ do not appear to work with any of these answers.

I tried pretty much all the solutions before upgrading Notepad++ to version 6.4.2.

xkcd 979

Tested Notepad++ versions:

  • 5.9 - not working - tested by namey
  • 6.4.2 - working - tested by Elysian Fields
  • 6.6.9 - working - tested by namey

For other versions your mileage may vary.

答案5

得分: 3

我分享了我在Notepad++ 6.5中找到的解决方案,因为我遇到了与之前的消息相同的问题。

  1. 如果还没有完成安装步骤,请按照go\misc\notepadplus\README中的说明进行安装(userDefineLang.xml,functionList.xml,APIs)。
    当你在Notepad++中没有useDefineLang.xml时,可以使用go\misc\notepadplus\useDefineLang.xml中的文件创建一个,但不要忘记添加第一行<?xml version="1.0" encoding="Windows-1252" ?>
    并取消注释NotepadPlus部分,使其在开头有<NotepadPlus>,在结尾有</NotepadPlus>

  2. 在functionList.xml中更改:<association ext=".go" id="go"/><association userDefinedLangName="go" id="go"/>

  3. 因为在Notepad++中默认没有userDefineLang.xml文件,所以我使用菜单Language -> Define your language -> Import导入了这个文件。
    然后停止/启动Notepad++。
    检查Go是否在Language菜单的末尾。
    打开一个.go文件。如果颜色没有自动更改,请在/Language菜单中点击go。

之后,对我来说一切都正常(缩进,颜色,自动完成等)。

英文:

I share the solution I found for Notepad++ 6.5, because I had the same issue than the previous messages.

  1. If not done, do the install steps explained in go\misc\notepadplus\README (userDefineLang.xml,functionList.xml,APIs).
    When you don 't have useDefineLang.xml in Notepad++, create one using the file from go\misc\notepadplus\useDefineLang.xml, but don't forget to add the first line &lt;?xml version=&quot;1.0&quot; encoding=&quot;Windows-1252&quot; ?&gt;
    and uncomment NotepadPlus part to have &lt;NotepadPlus&gt; at the beginning and &lt;/NotepadPlus&gt; at the end.

  2. Change in functionList.xml: &lt;association ext=&quot;.go&quot; id=&quot;go&quot;/&gt; BY &lt;association userDefinedLangName=&quot;go&quot; id=&quot;go&quot;/&gt;

  3. As I didn't have any userDefineLang.xml file by default in Notepad++, I imported this file using the menu Language &rarr; Define your language &rarr; *Import.
    Then stop/start Notepad++.
    Check that Go is in the Language menu at the end of the list.
    Open a .go file. If the color doesn't change automatically click on go in /Language menu

All were OK after that for me (indentation, color, autocompletion, etc.).

答案6

得分: 1

我将pl/sql语言语法添加到Notepad++中。语法/语言在网上可以找到。以下是我使其工作的方法...

  1. 使用Notepad打开XML文件,并在开头添加&lt;?xml version=&quot;1.0&quot; encoding=&quot;Windows-1252&quot; ?&gt;,就像David建议的那样。然后将其保存为userDefinedLang_plsql.xml
  2. 将文件粘贴到Notepad++的根目录中。
  3. 我还将其复制到C:\Program Files (x86)\Notepad++\plugins\APIs\,然后导航到菜单语言 &rarr; 用户定义,但没有任何效果。
  4. 因此,我转而进入菜单语言 &rarr; 定义您的语言,并从下拉菜单中选择pl/sql,并对其进行重命名,然后在该对话窗口中保存。

然后,新的语言将出现在语言对话框的末尾。

英文:

I added pl/sql language syntax to Notepad++. The syntax /language was on the web. Here's how I got it to work ...

  1. Open the XML file using Notepad and added &lt;?xml version=&quot;1.0&quot; encoding=&quot;Windows-1252&quot; ?&gt; to the very beginning, as David had suggested. Then save it to userDefinedLang_plsql.xml
  2. Paste the file in the Notepad++ root directory.
  3. I also copied it into C:\Program Files (x86)\Notepad++\plugins\APIs\, and navigated to menu Languages &rarr; Userdefined, but it did nothing.
  4. So, I then went to menu Languages &rarr; Define your language and selected pl/sql from the drop down, renamed it, and saved it in that dialog window.

The new language then it appeared in the language dialog at the end.

答案7

得分: 0

userDefineLang位于C:\Users\username\AppData\Roaming\Notepad++\userDefineLang.xml。

确保您的Notepad++安装在“C:\Program Files(86)”下,而不是“C:\npp.#.#.#.bin”文件夹下。

从https://notepad-plus-plus.org/download下载。或者直接谷歌搜索“下载Notepad++”。

在这里查看一个示例Scala语言的userDefineLang.xml文件:https://github.com/nfang/scala-syntax-highlighter

英文:

userDefineLang resides in C:\Users\username\AppData\Roaming\Notepad++\userDefineLang.xml.

Make sure your Notepad++ is installed under "C:\Program Files(86)", and not under "C:\npp.#.#.#.bin" folder.

And download from https://notepad-plus-plus.org/download. Or simply google "Download Notepad++".

Check out a sample Scala language userDefineLang.xml file here: https://github.com/nfang/scala-syntax-highlighter

答案8

得分: -1

如果您之前没有定义任何用户语言,那么在将userDefinedLang_Go.xml重命名为userDefinedLang.xml之后,还需要通过在文件的原始内容周围添加标签&lt;NotepadPlus&gt;&lt;/NotepadPlus&gt;来编辑文件的文本。

英文:

If you don't have any user languages defined before, then after renaming userDefinedLang_Go.xml to userDefinedLang.xml, also edit the text of file by adding the tags &lt;NotepadPlus&gt;&lt;/NotepadPlus&gt; around the original content.

huangapple
  • 本文由 发表于 2012年9月25日 07:02:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/12574121.html
匿名

发表评论

匿名网友

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

确定