User Defined language more folding in code styles
-
I have writen a user defined Language highligher using the built in editor
Language > User Defined Language > Define your languagehow do you do more than two folding code styles and one comment folding style ?
My language has at least 3 if, foreach and switch and has a multiline comment fold style
I have tried editing the xml and adding in
<Keywords name=“Folders in code3, open”>Switch:</Keywords>
<Keywords name=“Folders in code3, middle”>Case:</Keywords>
<Keywords name=“Folders in code3, close”>EndSwitch:</Keywords>
but that just gets ignored / removedAdditionally how do you add more than one middle ?
e.g.
if / elsif / else / endif
switch / case / default / endswitch -
@denwitham said in User Defined language more folding in code styles:
I have tried editing the xml and adding in …
You cannot just add new structures in the UDL XML definition and hope that Notepad++ would just magically understand what you meant.
how do you do more than two folding code styles and one comment folding style
You can mix multiple fold structures of the same type in the same boxes.
Folding in Code 1 is meant for things that fold that don’t require spaces surrounding it – so the c-style
{
…}
folding would be a primary use case for FiC1.Folding in Code 2 is meant for things that fold that do require spaces, like words, so that it will fold on “if” but not “gif” or “iffy”. So
if
/else elsif
/endif
would be one such set.Folding in Comments is intended as a way to add a prompt inside a comment that will do folding. for example,
=begin
and=end
as FoldingInComment with comment prefix of#
:
With multiple in the same box, like the if and switch constructs, you could technically trick N++ into doing folding on invalid combinations, like
if / case / endswitch
orswitch / else / endif
. So it’s imperfect, but N++ UDL isn’t meant as a code validator, and won’t enforce valid syntax.But since most languages require fully nested, most combinations will fold the way you expect:
You will notice that I earlier had a space between the
default
and the:
, because in FoldingInCode2, spaces are required. If you moved it over to FoldingInCode1, then you wouldn’t need that space: -
@PeterJones Thank you, just what I was looking for.