0

First off I've searched my hind end off for hours now trying to find an answer, but I can't seem to find anything remotely useful. What I am trying to do is to find a way to add in code-folding to the built in batch language. Basically I love using batch, but when I have tons of code, I want to be able to hide the code I do not need to edit which will make it easier to find the code I DO need to edit. What I want is to be able to make it so if I typed "::{" (without quotes) and have finished code in the middle and end with "::}" (also without quotes).

First question, is it possible? Can I add something like this (that one could normally add in the "user defined language") to the built-in batch language?

Next question, if not, where could I figure out how to basically re-create the batch language (and add my own twists) into a new "user defined language"?

Last question, if neither of those are possible, what are my other options?

Like I said, I've researched for hours. I'm not one to ask for help on forums, but I'm desperate at this point. All I want is to use the batch language and have code folding. Doesn't seem like too much to ask, but it might be!

Thanks!

Andrew
  • 11
  • 3
  • The code collapse you talk about is strictly a function of the editor you use. Writing your own language wouldn't help. You need an editor that allows you to specify your own language highlighting rules. – dbenham Jan 04 '15 at 21:01
  • possible duplicate of [notepad++ user defined regions with folding](http://stackoverflow.com/questions/3761206/notepad-user-defined-regions-with-folding) – rojo Jan 05 '15 at 00:23

1 Answers1

0

In Notepad++ you can define a language by going to the Language menu --> Define your language (at least in version 6.6.9 anyway). On the Folder & Default tab, under Folding in code 1 style, input a ( into the "Open" box. Input a ) into the "Close" box. Save this as "Windows Batch" (or at least something that doesn't conflict with the in-built language named "batch".

Until you define styles, it'll be ugly and unusable, but it should allow you to collapse / expand parenthetical code blocks as a proof of concept and see whether this project is worthy of further effort. Your next steps will be to copypaste batch keywords from %PROGRAMFILES(x86)%\Notepad++\langs.model.xml, and use the "batch" language styles from your favorite theme in Notepad++\themes\. If I were doing it, I'd input a few basic things using the GUI (like keywords, folding characters, etc.), then export to an XML file on the Desktop and copypaste the rest from a theme, search-&-replacing stuff as needed to massage the theme into your user-defined language. At the end, import your massaged XML into the Define your language dialog. It was going to be more effort than I felt like exerting, but your mileage may vary. If you decide to undertake this journey and you complete it, I hope you'll consider sharing your efforts.

This similar question has a few answers that suggest some workarounds you might find worthwhile -- in particular, hiding, rather than collapsing.

Community
  • 1
  • 1
rojo
  • 24,000
  • 5
  • 55
  • 101