Adding a user-defined language in Notepad++

2020-05-16 14:33发布

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.

8条回答
冷血范
2楼-- · 2020-05-16 14:55

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

查看更多
▲ chillily
3楼-- · 2020-05-16 14:57

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

C:\Users\[user]\AppData\Roaming\Notepad++
查看更多
登录 后发表回答