SACS syntax in ST3

Bentley’s SACS is the other suite I often use at work. So in the tradition of improving one’s own work environment, I extended syntax-highlighting for SACS input files with this public repository sacs_st. Here is a view of a couple of files syntax-highlighted in Sublime Text 3.

SACS input file syntax-highlighted in Sublime Text 3.

Recommended method of installation

With this package now available from Package Control,1 sacs_st can be installed from directly within Sublime Text 3. Here is how:

  1. From Tools, select Install Package Control… (Skip if already installed.)
  2. From Preferences > Package Control > Install Package, search for sacs and select.

Manual installation

Alternatively, if you have no access to internet or prefer a manual install then, download and place sacs.sublime-syntax file under Packages > User folder, which is accessible from Preferences > Browse Packages… menu.

Be sure to have SACS input files end with .inp for syntax highlighting to work.

Trivia

SACS commands are spread across its numerous manuals, and so it was an interesting exercise in amassing them all into a list first, and then sort them to remove duplicates. But before doing so, I wanted to see which ones were repeated. So I wrote this script to find out:

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Find most common sacs commands across modules
# 2020 ckunte

import re
from collections import Counter

# read a file containing all sacs commands
commands = re.findall(r'\w+', open('sacs-commands-all.txt').read())

# print 85 most common commands across all sacs modules
mcom = Counter(commands).most_common(85)
for com, nos in mcom:
    print("{:<12}{:<9}".format(com, nos))

The number 85 in the code above is arbitrary. I tried a few others before like 100, 90, until single occurrences of commands reduced to just a couple. Now that I think of it, there is an even simpler way to sort unique list of commands using a chained shell commands2 like so:

curl https://gist.githubusercontent.com/ckunte/d4bd35e2ac07dc6d575d95c60a61a8ef/raw/07cdd051893455544cac2185c08a83aab3e468e1/sacs-commands-all.txt | sort | uniq -c | sort -nr | grep -v "#"

  1. Available from Package Control as of December 13, 2020. 

  2. The remote file is first downloaded to memory using curl, which is then fed to sort, whose output is then checked for unique items (with repeats counted) using uniq -c, the result of which is sorted in descending order with sort -nr, whose output is filtered removing all lines with #, since these are SACS module titles/comments but not commands themselves.