Adding a new language to Notepad++

20

10

What's the easiest way to add a custom language to Notepad++ for highlighting support? After some research, I see two ways:

  • User-Defined Language: simple way of adding a new language based on tokens, but can't use the default color scheme (colors are assigned absolutely)?
  • Lexer plugin: A custom C++ plugin implementing a new Scintilla lexer: extremely complex, but tons of flexibility.

Are these it? My one complaint is that with the UDL feature, if I want something to be highlighted, I need to assign it a color; there doesn't seem to be any way to say "use the default keyword color".

Any advice?

jjkparker

Posted 2010-07-07T14:05:39.647

Reputation: 645

1

In teh past I have been followed this tutorial to add my own custom highlighting: http://weblogs.asp.net/jgalloway/archive/2006/11/25/creating-a-user-defined-language-in-notepad.aspx Hope this help

– Angelodev – 2010-07-07T14:11:12.697

I don't see a "default keyword color" in Notepad++, although there is a default style that includes all text. Assuming this is what you want, create your style, then open userDefineLang.XML and delete fgColor="xxxxxx" for the appropriate keyword group. This should allow you to use the default style color. – jdigital – 2012-05-26T19:35:20.110

One tip I have: always refer to using Notepad++ "Plugin Manager" first before assuming there is any functionality not already there. – djangofan – 2012-06-19T23:33:23.420

Answers

7

If you are talking about using the colors based on those set in the Settings > Style Configurator... for the default keyword color...

You can do this by right-clicking on the color in the Colour style section. It will place hatch lines over the color to indicate "use default color".

Npp Screenshot

Now when you change the color theme the theme's color will be used instead of the UDL defined color.

Ryan_S

Posted 2010-07-07T14:05:39.647

Reputation: 624

3

It is possible;

I have found an answer that may or may not be helpful depending on how much time you currently have. I found out that in ©Notepad++, you can define your own unique format of a language and have it highlighted however you please, on the contrary of having to input all that you would have to do, it may be a very time consuming and tedious process. However here are the instructions:

1.) 'View' > 'User Defined Language'> Create New > [NAME] > Enter

For version 6.1.2 and later,

2.) 'View' > 'User Defined Dialogue' (presented with wizard/dialogue)

After that you must read my source of this information for adding your own techniques etc. and may the best of luck be with you!


Source(s):

weblogs.asp.net

tincopper2

Posted 2010-07-07T14:05:39.647

Reputation: 53

1

There is an easy way.

Take a look here: http://www.macroquest2.com/wiki/index.php/Notepadplusplus_Syntax_File

Use http://www.w3schools.com/tags/ref_colorpicker.asp to get the "color string" (RGB hex color number) by clicking on the left grid for the color, on the right for the shade of that color, and the color itself with its "string" on the bottom.

In the notepad++ userDefinedLang.xml there's a section for setting the colors as desired:

<Styles>
    <WordsStyle name="DEFAULT" styleID="11" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
    <WordsStyle name="FOLDEROPEN" styleID="12" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
    <WordsStyle name="FOLDERCLOSE" styleID="13" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
    <WordsStyle name="KEYWORD1" styleID="5" fgColor="0080FF" bgColor="FFFFFF" fontName="" fontStyle="0" />
    <WordsStyle name="KEYWORD2" styleID="6" fgColor="800000" bgColor="FFFFFF" fontName="" fontStyle="1" />
    <WordsStyle name="KEYWORD3" styleID="7" fgColor="FF8040" bgColor="FFFFFF" fontName="" fontStyle="1" />
    <WordsStyle name="KEYWORD4" styleID="8" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" />
    <WordsStyle name="COMMENT" styleID="1" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="0" />
    <WordsStyle name="COMMENT LINE" styleID="2" fgColor="008040" bgColor="FFFFFF" fontName="" fontStyle="1" />
    <WordsStyle name="NUMBER" styleID="4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
    <WordsStyle name="OPERATOR" styleID="10" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
    <WordsStyle name="DELIMINER1" styleID="14" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
    <WordsStyle name="DELIMINER2" styleID="15" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
    <WordsStyle name="DELIMINER3" styleID="16" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
</Styles>

pashute

Posted 2010-07-07T14:05:39.647

Reputation: 171