Sublime Forum

IBM SPSS Syntax Highlighting

#1

HI, struggling researcher here :grimacing:,

Has anyone by chance managed to make a syntax highlighting to write IBM SPSS Command Syntax in Sublime? I am just too inexperienced and have not managed to code it by myself and on the internet I have only found a Textpad syntax (.syn) – but I have no clue if I can convert it or not and how…
I would appreciate it greatly if somebody could help me out!
Thanks a lot in advance!

0 Likes

#2

Do you have the link for the language specification?

0 Likes

#3

Looking at the syn file, it is highlighting everything that’s builtin as keyword(even functions), if that’s already good enough for you, it should simple to convert.

0 Likes

#4

Hi Alexandre @borela,
yeah, just highlighting the keywords would be wonderful, could you give me a hand converting it? Or point me in the right direction as to how to do it?
Thanks so much :smile:

0 Likes

#5

You could create a file ibm.spss.sublime-syntax (the name doesn’t matter, just the extension):

name: IBM SPSS

file_extensions:
  - someExtension

scope: source.ibm.spss

contexts:
  main:
    # Strings.
    - match: \"
      scope: punctuation.definition.string.begin.ibm.spss
      set: string
    # Operators.
    - match: "[-+*/<>~=:,;]"
      scope: keyword.operator
    # Keywords.
    - match: |
        (?xi)
        (?> keyword1
          | keyword2
        )\b
      scope: keyword

  string:
    - meta_scope: string.quoted.double.ibm.spss
    - match: \"
      scope: punctuation.definition.string.end.ibm.spss
      pop: true

In (?xi), the x means to ignore spaces, the i to ignore the case. This is a very rough system, with the language specification it could in theory(in theory because I am not familiar with SPSS, I would need at least samples of code to analyse) be possible to differentiate function calls from keywords.

0 Likes

#6

Ok, thank you so much for your help! I will try to make something based on your indications. If I produce something useful I will post it here so other people can use it :slight_smile:
Have a nice day!

0 Likes

#7

You’re welcome, If possible, publish your package on github and package control so that others can install your custom syntax easily.

0 Likes

#8

hi janina,
i’m actually trieing to find out, if sublime can be used with imb spss. do you have some hints for me?
winfried

0 Likes

#9

Hi @winfried , I am pretty sure it can be used, for example for writing syntax, but I have next to none programming/coding skills so I was not able to make the file to enable syntax highlighting myself… :sweat:
For what exactly do you want to use it?

0 Likes

#10

hi!
i am searching for a tool to code in spss, R, stata and python. i am pretty sure, that R and python is covered by sublime. but what about spss? that program ist pretty much used in my company here.
lg winfried

0 Likes