54

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Brendan Tracey
  • 656
  • 1
  • 5
  • 5

8 Answers8

56

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

C:\Users\[user]\AppData\Roaming\Notepad++
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
jblaufuss
  • 577
  • 4
  • 4
  • 6
    Thanks, that worked for me. I also changed the colours to be similar to the defaults that Visual Studio uses. I've put it here in case anyone else needs it: [Notepad++ syntax file for golang - with VS colours](http://pastebin.com/YpQcDnk3) – dodgy_coder Jun 19 '13 at 07:43
  • 7
    You could also use %APPDATA%\Notepad++ as a shortcut. – rxantos Jul 02 '15 at 18:20
  • notepad++ repository link is change into this: https://npp-user-manual.org/docs/user-defined-language-system/ – abanmitra Sep 13 '21 at 05:46
17

New install of Notepad++ 6.4.5 on Windows 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\\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++.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
anon
  • 171
  • 1
  • 2
  • 6
    So the only thing missing in the process described in the question is uncommenting the `` tags? Pointing that out would be very helpful. – Kissaki Aug 19 '13 at 21:29
  • I do not have this directory, only `App`,`Data`,`Other`,`XMLplugin`. I put the file `userDefineLang.xml` into the latter, uncommented, but it did not work. – B--rian Feb 20 '19 at 11:31
  • I should mention that I use Notepad++ portable and that I also tried `Notepad++/App/Notepad++/plugins/APIs`. Any ideas? – B--rian Feb 20 '19 at 11:37
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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
David
  • 2,053
  • 2
  • 16
  • 26
  • 2
    That doesn't appear to work for me. Is it possible I have a different encoding number? When you say at the top, do you mean literally the first line, or should it be after or – Brendan Tracey Sep 25 '12 at 02:20
  • This is the userDefinedLang (I accidently named it userDefineLang) - http://pastebin.com/A4WA7bZc This is the go.xml - http://pastebin.com/Cq0SL47g See if those work, remember, you need to close Notepad++ and then reopen it for it to work. – David Sep 25 '12 at 10:36
  • 1
    @user1695784 for me the trick was to open the userDefineLang.xml in Notepad++ and put at the beginning and at the end. But don't forget to indent the content between the tags one step. (Select everything in between and press tab). Restart notepad and import it again. – Aron Mar 17 '13 at 18:33
  • 1
    This didn't work for me, it needed to be put in the "roaming" folder as described in another answer. – dodgy_coder Jun 19 '13 at 06:57
4

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
enderland
  • 13,825
  • 17
  • 98
  • 152
  • @Kissaki I can delete this answer if you would prefer. Let me know if you don't think it adds any value. I assumed that since none of the existing answers solved my problem (too old a version of Notepad++) this may benefit others. If you don't think so I will delete it! – enderland Aug 19 '13 at 23:01
  • 2
    It is arguably useful. Feel free to keep it. It would be a lot more useful though if it would be specific about limits - which versions it does not work with. Not sure how useful it is like this, but don’t take a single comment (mine, with no upvotes) as a basis to remove it already. :) – Kissaki Aug 19 '13 at 23:07
  • 1
    Was useful to me - I was still stuck with 5.9 and none of the above worked. Updating to the latest (6.6.9 now) solved it immediately. – namey Nov 08 '14 at 14:00
  • @namey great! Glad it was helpful to someone. There's not much out there about this :) – enderland Nov 08 '14 at 17:56
3

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 <?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 didn't have any userDefineLang.xml file by default in Notepad++, I imported this file using the menu LanguageDefine your language → *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.).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dam
  • 39
  • 2
  • Upvoted just because it helped me troubleshoot when Notepad++ was deleting `userDefineLang.xml` every time I closed. By setting a .vm file to Velocity language, it seemed to realize it should keep the XML file around. – Noumenon Dec 18 '19 at 01:00
1

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 <?xml version="1.0" encoding="Windows-1252" ?> 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 LanguagesUserdefined, but it did nothing.
  4. So, I then went to menu LanguagesDefine 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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Nilhan
  • 11
  • 2
0

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

TheWalkingData
  • 1,007
  • 1
  • 12
  • 11
-1

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131