Sublime Text TM1 syntax highlighter

Post Reply
hermie
Posts: 3
Joined: Wed Jul 22, 2015 6:00 pm
OLAP Product: TM1
Version: PA 2.0.x
Excel Version: 2010

Sublime Text TM1 syntax highlighter

Post 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
Last edited by hermie on Wed Sep 20, 2017 9:20 pm, edited 1 time in total.
JDLove
Posts: 49
Joined: Thu May 21, 2009 1:16 pm
OLAP Product: TM1
Version: 10.1
Excel Version: 2007

Re: Sublime Text TM1 syntax highlighter

Post 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
Paul Segal
Community Contributor
Posts: 306
Joined: Mon May 12, 2008 8:11 am
OLAP Product: TM1
Version: TM1 11 and up
Excel Version: Too many to count

Re: Sublime Text TM1 syntax highlighter

Post 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.
Paul
JDLove
Posts: 49
Joined: Thu May 21, 2009 1:16 pm
OLAP Product: TM1
Version: 10.1
Excel Version: 2007

Re: Sublime Text TM1 syntax highlighter

Post 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
Paul Segal
Community Contributor
Posts: 306
Joined: Mon May 12, 2008 8:11 am
OLAP Product: TM1
Version: TM1 11 and up
Excel Version: Too many to count

Re: Sublime Text TM1 syntax highlighter

Post by Paul Segal »

Did you install RegReplace? This is required for the convert bit to work.
Paul
JDLove
Posts: 49
Joined: Thu May 21, 2009 1:16 pm
OLAP Product: TM1
Version: 10.1
Excel Version: 2007

Re: Sublime Text TM1 syntax highlighter

Post 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 :?
hermie
Posts: 3
Joined: Wed Jul 22, 2015 6:00 pm
OLAP Product: TM1
Version: PA 2.0.x
Excel Version: 2010

Re: Sublime Text TM1 syntax highlighter

Post 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).
Post Reply