Thursday, February 7, 2013

Setting Standard ML plugin in Sublime Text 2

Of late, I was stuck with writers block when it came to updating my blog with the awesome things that I find over internet or my learning and musings.
These days I am busy taking Programming Languages course that teaches SML, Racket and Ruby. It recommends emacs as a preferred editor, but I happen to use Sublime Text 2. One of the caveats of using sublime as a text editor was it did not had any plugin to highlight syntax for sml language (or this was what I thought after searching first).
However, I stumbled upon a plugin manager that led me having this plugin installed quite easily. Here is what I did.

  • Opened up console (view>Show Console) and pasted the following python code to install sublime package manager:
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation')
  • Restarted the editor
  • Now selected the newly formed menu (Preferences > Package Control) and selected install package option.
In case it did not straightaway apply coloring over already opened sml files, you can use set syntax to sml through command palette (Tools > Command Palette) Set Syntax : SML.