After recovering from a bad windows update most of the programs that I typically use have been installed, all but for Sublime Text. I use several packages with Sublime Text, and it can be a tricky process to make sure that everything works properly. As such, this is a good chance to record the process of what’s involved with the installation.

The tasks needed to be done to fully install Sublime Text with added packages is:

  • Install
  • License key
  • Global access
  • Package control
  • Wallaby
  • Sublime Linter

Install Sublime Text

First of all it needs to be downloaded and installed, and have my previous licence key applied to the program.

Licence key

Fortunately my licence key is recorded in a previous email. It would be silly though to reveal it here.

I cannot enter my licence, as I’m told “Unable to write license file”. This occurred because the owner of the file is currently administrator.

When I transferred over my documents from a previous account, I changed the owner and permissions of my documents, music, pictures, and videos, but I failed to do so on my AppData folder. That fix gets to happen now by right-clicking on my C:\Users\PaulM\AppData folder, and going to properties > security > advanced. I can then change the owner, and turn on both of the following checkboxes:

[X] Replace owner on subcontainers and objects

[X] Replace all child object permission entries with inheritable permission entries from this object

After that, when I close and restart Sublime Text, my licence key is properly accepted.

Open from anywhere

You can open Sublime Text from the command line with subl.exe which you can copy in to the c:\windows\system32\ directory to let you run sublime text from the command prompt.

Package Control

Making it easier to install packages is the next stage. Package Control is the website that you go to to install package control, where in Sublime Text you open the console with ctrl+` and run the following complex command:

import urllib.request,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

Now that package control is installed, I have an easy built-in way to install the packages that make life easier for me in the text editor.

Wallaby

Wallaby provides integrated and continuous testing for your code, so that you can gain immediate feedback within your code editor.

Installing Wallaby is as easy as running the package installer and following the instructions from the Wallaby Sublime tutorial. To test that it’s working though, you’ll find it easier once you install GIT.

Node

Before we can start using Wallaby, we need to make sure that we have installed Node.

GIT

The Wallaby install guide uses a sample calculator app for testing, which in turn requires a git repository to be downloaded, so installing git is a good first step. Once installed we can go to the command prompt, make a suitable directory, and issue the command:

> cd documents
> mkdir programming
> cd programming
> git clone https://github.com/wallabyjs/calculator-sample.git

After earlier making subl.exe accessible, we can now easily open the calculator-sample folder in Sublime Text with:

> subl calculator-sample

From there, we can go to one of the src or test files, use Ctrl+Shift+fullstop to show the Wallaby list of commands, and select Start.

All going well, you should now see green/orange/grey squares that indicate lines covered by existing tests, partially covered, or not yet covered by tests.

wallaby

Sublime Text with Wallaby

Licence Wallaby

Now that Wallaby is running well, I will have 30 days to try it out before needing to enter my licence details. I bit the bullet, so to speak, and went for the $140 freedom licence, as I haven’t found any free solutions that are as useful or beneficial as this tool.

JSLint

This is required for use by me with Sublime Linter. It can be somewhat tricky to configure the Node version of JSLint to support ES6 JavaScript code.

If we are to use jslint, it requires the node version of jslint, so from the command line perform a global install of jslint:

> npm install -g jslint

Sublime Linter

The Sublime Linter provides a nice way to add linting for a wide variety of files. In this case my focus is on linting with jslint.

The generic linter itself is installed from the install packages area, called SublimeLinter.

Now we can use Sublime Text to install the package called SublimeLinter-contrib-jslint, and the JavaScript code should now be linted as you type.

You might have a color theme conflict with Wallaby, where you are told:

Unable to open Packages/Color Scheme - Wallaby/Monokai (SL).tmTheme

If that happens, choose the appropriate color scheme from the menu called Preferences > Color Scheme > User > Sublime Text and the problem should resolve itself.

If you continue to have trouble though, it could be a window view that’s causing trouble, so use the Sublime console with Ctrl+Shift+` to remove the color scheme from the open window views too.

[ v.settings().erase("color_scheme") for views in [ w.views() for w in sublime.windows() ] for v in views ]

Other packages

Those were the more complex of the packages that needed installing, and I can now go ahead with installing other packages such as:

  • Sublime Tutor
  • SublimeCodeIntel
  • Diffy
  • Markdown
  • VB Script (for GW-Basic code)

The worst of the Sublime Text configuration has occurred now though, and it’s now all ready for proper use.

Advertisements