Page 1 of 1

Sublime Text TM1 syntax highlighter

Posted: Fri Apr 21, 2017 9:18 pm
by hermie
I created a dark TM1 syntax highlighting package for the excellent text editor Sublime Text (see https://www.sublimetext.com/), as an alternative to the Notepad++ version. It includes all functions of TM1 10.3.
For me it's easier to read and easier on the eyes. It also includes a feature to automatically convert all TM1 functions to the captitalization as per IBM Cognos TM1 Reference Guide. Several other topics are on the TODO list.

Image

Further details here: https://github.com/hermie64/tm1-sublime

Setting up "Package Control" (plugin manager) in Sublime Text can be a bit daunting. If you don't want to go through this but still want to give it a try, please PM me and I can send you the link to a portable 64-bit version of Sublime Text that is configured for TM1 syntax highlighting and includes all recommended Sublime Text plugins for TM1 (see link above for further details).

Image

Re: Sublime Text TM1 syntax highlighter

Posted: Mon Apr 24, 2017 6:00 am
by JDLove
Hi I'm interested to try like the look.

I've
- downloaded and installed Subline Text 3
- added the package control to Sublime Text 3

Where is that folder structure required to copied the TM1 folder and other files in ?
Step 2."Copy GitHub folder TM1 to ..\Sublime Text\Data\Packages\User\TM1"
Step 4."Copy the three files in GitHub folder RegReplace to ..Sublime Text\Data\Packages\User"


Thanks
JDLove

Re: Sublime Text TM1 syntax highlighter

Posted: Mon Apr 24, 2017 6:55 am
by Paul Segal
This will be in your user directory settings, so for me this is c:\users\psegal\appdata\roaming\sublime text 3\packages\user. Obviously you need to change as appropriate for your username etc.

Re: Sublime Text TM1 syntax highlighter

Posted: Mon Apr 24, 2017 10:44 am
by JDLove
Thanks Paul,
Paul Segal wrote:This will be in your user directory settings, so for me this is c:\users\psegal\appdata\roaming\sublime text 3\packages\user. Obviously you need to change as appropriate for your username etc.
Now having copied the 3 files to the directory and restarted "Sublime Text 3". I dont see the tm1 options as packages to install.
I restarted and the Package Control is working and I also have the basic TM1 formatting working.

"Automatically convert all TM1 functions to capitalization as per IBM Cognos TM1 Reference Guide:
Shortcut: Ctrl+Shift+P >> type tm1… and choose Strict Naming"



JDLove

Re: Sublime Text TM1 syntax highlighter

Posted: Mon Apr 24, 2017 10:57 am
by Paul Segal
Did you install RegReplace? This is required for the convert bit to work.

Re: Sublime Text TM1 syntax highlighter

Posted: Mon Apr 24, 2017 1:10 pm
by JDLove
Thanks Paul that was what I missed !
Did you install RegReplace? This is required for the convert bit to work.
Not the easiest to install, but I suspect mostly it was me not following instructions carefully :?

Re: Sublime Text TM1 syntax highlighter

Posted: Sun Apr 30, 2017 9:19 pm
by hermie
Updates to syntax highlighting:

1. Added undocumented "Break" function.

2. All internals of .pro and .rux (FORMAT==100) files are now displayed in orange, and the "Strict Naming" script ignores these orange lines.
If data source is set to a View, TM1 inserts NVALUE, SVALUE, VALUE_IS_STRING into the .pro file. Because these are not spelled as in the Reference Guide, the script would also update them (unless you had the script work on a selection).

Image

3. I added a new experimental script "Prettify" that updates code to my preferred style.
It's not yet perfect because it doesn't handle functions that are split over multiple lines correctly, but it already helps me in its current state.

It performs following actions:
- Replaces tabs with two spaces
- Add spaces around operators (+ - * = | etc.)
- Deletes spaces between function and opening parenthesis
- Replaces multiple spaces with one space within functions
- Deletes spaces before comma
- Deletes spaces before semicolon
- Deletes spaces inside empty pair of parenthesis
- Deletes spaces after tilde
- Adds single space after opening parenthesis and before closing parenthesis
- Trims trailing spaces

This scipt excludes comment, strings, and TM1 internals (orange).