Page 1 of 1

Syntax highlighting? a) in Vensim, b) text exported from Vensim

Posted: Wed May 20, 2020 9:52 am
by kleemax
Syntax highlighting? a) in Vensim, b) text exported from Vensim

Vensim syntax can sometimes become cumbersome to understand (esp. if one tries to understand a model that someone else has built... :? )
Many programming languages feature text highlighting see:https://en.wikipedia.org/wiki/Syntax_highlighting, which makes understanding code much easier.

For example in Vensim it would be helpful if comments had a special color and built-in functions had a special color etc. Ideally different levels of nested parenthesis could also have differing colors.
"View as text" also contains headings if subgroups are defined for variables that could be colored.


I see two avenues with different time horizons:

a) on the medium to long term it would be helpful to have text highlighting implemented in Vensim (esp. "equation editor" and "view as text") Please let me know if I should I post this as a feature request somewhere else, too.

b) on the short term it would be easiest to export text (copy-paste) into a text editor that supports syntax highlighting. Importantly, the text editor would need support defining custom syntax highlighting for programming languages that are not already included with the software. I wonder if anyone has ever used this approach? Is there a format for the definition of syntax highlighting that can be shared (exported by one text editor and imported by another one)? Inter-operability between Windows and Mac would also be desirable in this sense.

Re: Syntax highlighting? a) in Vensim, b) text exported from Vensim

Posted: Wed May 20, 2020 10:26 am
by Administrator
We have already build a new text editor for Vensim that includes syntax highlighting for things like VOC files. It will be in the 8.1 release of Vensim when using the new sketch tool.

I don't see how syntax highlighting for a model would work. The Vensim language is not like C/C++ where the language is well defined. We will include highlighting for the Vensim functions, there is not much else we can do though.

Re: Syntax highlighting? a) in Vensim, b) text exported from Vensim

Posted: Wed May 20, 2020 5:58 pm
by tomfid
Notepad++ has definable highlighting. Not sure how helpful it would be, but seems interesting to try.

Re: Syntax highlighting? a) in Vensim, b) text exported from Vensim

Posted: Thu May 21, 2020 9:35 am
by kleemax
@ administrator: cool that you are implementing it for some aspects in the next release. I'm not sure what you mean by the "new sketch tool", but I guess that's just because I use 7.3.4?

Re: Syntax highlighting? a) in Vensim, b) text exported from Vensim

Posted: Thu May 21, 2020 9:37 am
by kleemax
I have found that on the Mac it may be possible by using BB-Edit:
http://www.barebones.com/support/bbedit ... brary.html
http://www.barebones.com/support/develop/clm.html
It's a bit difficult for me because I'm not a programmer by education, but it looks promising

Re: Syntax highlighting? a) in Vensim, b) text exported from Vensim

Posted: Thu May 21, 2020 9:48 am
by kleemax
I am not sure what administrator means by "well-defined" Let me explain what I would like to do:
all comments in variables look like this in text view
~ comment first line \
comment second line \
|

I mean all comments are in between a tilde "~" and a "|"
Hence it should be possible to give them a defined color (e.g. orange as above).
Similarly, take a function like Delay N, it has a defined syntax DELAY N( _in_ , _dtime_ , _init_ , _order_ ). Hence it should e.g. be possible to color all of these in blue (as I have done above)

Re: Syntax highlighting? a) in Vensim, b) text exported from Vensim

Posted: Thu May 21, 2020 10:24 am
by Administrator
kleemax wrote: Thu May 21, 2020 9:48 am I am not sure what administrator means by "well-defined" Let me explain what I would like to do:
all comments in variables look like this in text view
~ comment first line \
comment second line \
|

I mean all comments are in between a tilde "~" and a "|"
The problem is that all text editors I know of, to highlight syntax, you specify key words. To highlight the comment in your example, we need to tell the text editor that the key words are "comment", "first", "line" and "second". This also means that every occurance of those words would also be highlighted, which is not what is needed.

Re: Syntax highlighting? a) in Vensim, b) text exported from Vensim

Posted: Thu Jun 04, 2020 9:56 am
by kleemax
tomfid wrote: Wed May 20, 2020 5:58 pm Notepad++ has definable highlighting. Not sure how helpful it would be, but seems interesting to try.
Here is a link that outlines what Notepad++ could do in this respect:
https://npp-user-manual.org/docs/user-d ... ge-system/

Re: Syntax highlighting? a) in Vensim, b) text exported from Vensim

Posted: Thu Jun 04, 2020 10:07 am
by Administrator
kleemax wrote: Thu Jun 04, 2020 9:56 amHere is a link that outlines what Notepad++ could do in this respect:
https://npp-user-manual.org/docs/user-d ... ge-system/
If you manage to create a syntax highlighter, send it to us and we will add it to the workbench page on vensim.com.