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

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

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

Any idea what I'm doing wrong? I'm using a clean installation of Notepad++, which is version 6.1.8.

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:

<?xml version="1.0" encoding="Windows-1252" ?>

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.

Hope that helps.

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

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

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.

http://xkcd.com/979/

UPDATE:

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

Other versions, YMMV.

New install of Notepad++ 6.4.5 on Win7 64bit

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

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

  • Copy "userDefineLang_Go.xml" to C:\Users\\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++

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 otepadplus\README (userDefineLang.xml,functionList.xml,APIs). When you don 't have useDefineLang.xml in NP++ create one using the file from go\misc otepadplus\useDefineLang.xml but don't forget to add the first line <?xml version="1.0" encoding="Windows-1252" ?> and uncomment NotepadPlus part to have <NotepadPlus> at the beginning and </NotepadPlus> at the end

  2. Change in functionList.xml <association ext=".go" id="go"/> BY <association userDefinedLangName="go" id="go"/>

  3. As I had no userDefineLang.xml by default in NP++ I imported this file using the menu Language/Define your language -> import. Then stop/start NP++. 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 ...)

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: pp.#.#.#.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

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 tags <NotepadPlus></NotepadPlus> around original content

I added pl/sql Language syntax to notepad++, the sytax/ lang was on the web, Here's how I got it to work ..

  1. Opened the xml using notepad, and add to at the very beginning <?xml version="1.0" encoding="Windows-1252" ?> as David had suggested. Then save it to userDefinedLang_plsql.xml
  2. Paste the file in notepad++ root directory.
  3. I also copied it into C:\Program Files (x86)\Notepad++\plugins\APIs\, and navigated to languages > userdefined, but it did nothing.
  4. So, I then went to languages > define your language and selected pl/sql from drop down, renamed it and saved it in that dialog window.

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