Skip to content

IBM Cognos TM1 syntax highlighting for Sublime Text

Notifications You must be signed in to change notification settings

hermie64/tm1-sublime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tm1-sublime

IBM Cognos TM1 syntax highlighting for Sublime Text

screenshot

Installation

For syntax highlighting you only need to go through steps 1 and 2.
Step 3 is optional and sets the defaults for tabs in TM1 files (tab size is 2 spaces, 2 spaces are inserted when tab is pressed).
If you want to use feature 4 to convert functions to the form as in the IBM Cognos TM1 Reference Guide, you additionally need to follow steps 4 and 5.

  1. Get Sublime Text here and install it (also available as portable version for Windows)
  2. Copy GitHub folder TM1 to ..\Sublime Text\Data\Packages\User\TM1
  3. Copy GitHub file TM1.sublime-settings to ..Sublime Text\Data\Packages\User
  4. The feature to convert functions to the form as in IBM Cognos TM1 Reference Guide, requires installation of the RegReplace package (plugin). The easiest way to deal with the installation of plugins in Sublime Text is via "Package Control" (plugin manager for Sublime Text).
    a. So first install Package Control. Instructions can be found here.
    b. Next, install required RegReplace package & recommended packages. See aforementioned link and then the instructions under "Usage" (regarding step 2, when typing, look for "Install Package").
    A video that shows steps a and b is available here.
  5. Copy the three files in GitHub folder RegReplace to ..Sublime Text\Data\Packages\User

Usage

  1. Set color scheme for TM1 syntax highlighting: Preferences >> Color Scheme >> User >> TM1 >> TM1_Sublime
    Other available color schemes are: TM1_Sublime_Highlight_Loose (see Feature 3) and TM1_NotepadPP
    (TM1_NotepadPP theme was created by Ambrus Vancso)
  2. To assign TM1 syntax highlighting to a file: View >> Syntax >> TM1, or click current syntax in bottom-right corner, and choose TM1
    screenshot
  3. Automatically convert all TM1 functions to capitalization as per IBM Cognos TM1 Reference Guide:
    Shortcut: Ctrl+Shift+P >> type tm1… and choose Strict Naming
    screenshot
    Will be applied to whole file if no selection exists

Features

  1. The TM1 syntax highlighting is based on the Notepad++ version, but it has a dark theme to improve on readability.
    a. Background is dark, but not completely black
    b. Comments are displayed in dark gray
    c. Strings are displayed in yellow
    d. Numbers are displayed in purple
    e. Operators like = , ; ( ) + etc. are displayed in dark red
    f. TM1 control statements like If, While etc. are displayed in green
    g. Majority of TM1 functions is displayed in light blue and bold
    h. TM1 functions without arguments are displayed in green and bold
    i. TM1 variables are displayed in yellow and bold
    j Specific rules functions like FEEDERS, FEEDSTRINGS and SKIPCHECK are displayed in pink and bold
    k. Everything else is displayed in white

  2. The Notepad++ version hasn’t been updated for years. The Sublime Text version includes all functions from TM1 version 10.3.

  3. The Notepad++ syntax highlighter supports 3 "flavors" of functions (all uppercase (CELLPUTN) , all lowercase (cellputn), and case according to IBM Cognos TM1 Reference Guide (CellPutN).
    The Sublime TM1 syntax highlighter highlights all functions regardless of their capitalization, but it highlights the functions that are not capitalized according to Reference Guide in italics.
    screenshot
    These italics are not really in your way when reading code, but still visible enough to notice that the function is not written "correctly".
    I included an additional version of the syntax highlighter that will show these “incorrect” functions with inversed colors so that these really stand out.
    screenshot

  4. I included an additional feature that will automatically convert all functions to the form as stated in the IBM Cognos TM1 Reference Guide.
    You simply run a command and everything will be adjusted to correct and consistent form.
    screenshot
    screenshot

Required Sublime Text package

  1. RegReplace: Sublime Text plugin for creating regex (regular expressions) find and replace sequences

Recommended Sublime Text Packages

  1. Package Control: The Sublime Text package manager: https://packagecontrol.io/
  2. Alignment: Alignment of selections
    Shortcut: Ctrl+Alt+A
    Before:
    screenshot
    After:
    screenshot
  3. All Autocomplete: Extends the default autocomplete to find matches in all open files. By default Sublime only considers words found in the current file
  4. AppendSemiColon: Appends semi colon at the end of a line (regardless of where the cursor is positioned on a line) Shortcut: Ctrl+;
  5. Expand Selection to Quotes: Expands selections to the closest containing pairs of single or double quotes
    Shortcut: Ctrl+’
    screenshot
  6. SideBarEnhancements: Enhancements to Sublime Text Side Bar
    screenshot
  7. Trimmer: For cleaning up whitespace
    Shortcut: Trim Trailing Whitespace: Ctrl+Alt+S
    screenshot

Sublime Text

A couple of Sublime Text features that I would like to emphasize:

  1. Sublime Text has a Side Bar that acts as a file browser. You can drag folders and files onto this Side Bar and browse/preview processes and rules without ever leaving the editor.
  2. It includes a Minimap that displays the open file and allows for very quick navigation (faster than scrolling).
  3. A feature that makes it rather unique is “multiple cursors”.
    a. Alt+F3 gives a really simple way to do find and replace: Use it to select all occurrences of the current word or selection, then just start typing to replace or edit them all at once.
    b. Use multiple selections to edit in more than one place at once. It works as a quick substitute for find and replace, or to apply the same sequence of changes to multiple lines simultaneously.
    To select multiple regions using the keyboard, select a block of text, then press Ctrl+Shift+L to split it into one selection per line.
  4. Toggle Comment (works on multiple lines)
    Shortcut: Ctrl+/
    screenshot
  5. I pre-configured Sublime Text so that:
    a. Trailing whitespace is automatically trimmed on save.
    b. If not present, an empty new line at eof is created on save.
    See file Other_Assets\Preferences.sublime-settings.
  6. If you don’t like the default font of Sublime Text, here are couple of good suggestions for coding fonts: http://t3n.de/news/coding-fonts-8-besten-schriften-678847/
    I’m using for example the “Input” font and that’s also the font you see in the screenshots.

TODO

  1. Code suggestions will be given as you type and code snippets can be inserted (tab key will allow you to jump from argument to argument).
    screenshot
    screenshot
  2. Since Sublime Text includes a Python-based plugin API, I’m currently investigating the options to incorporate a Python-based interface to the TM1 REST API (see https://github.com/MariusWirtz/TM1py) as a Sublime Text plugin.
    That would enable “hot deployment” of processes and rules through the TM1 REST API. This means that you could code/update processes and rules in Sublime Text and deploy directly to TM1 without a restart.
  3. TM1 code prettifier.

About

IBM Cognos TM1 syntax highlighting for Sublime Text

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages