Tuesday, September 17, 2013

How to Install Package Control in Sublime Text 3

We all know about Sublime Text (hopefully) so I'm not going to waste your time introducing this text editor. My aim for this post is to let you know how you can install the Package Control in Sublime Text 3. 

Note: If you want to know about the installation of the Package Control for Sublime Text 2, read my other post where I've briefly discussed the procedure.

What is Package Control?
It's basically a package or plugin manager for Sublime Text that allows a user to find, install, upgrade and remove Sublime Text packages. It supports packages from GitHub and BitBucket as well. By default, the Package Control isn't installed in Sublime Text but with some easy-to-follow steps it could be installed.

How to Install Package Control
Since the release of Sublime's version 3 (beta) on 29th January 2013, almost everyone was confused about the procedure to install the Package Control. Some people posted tutorials for its installation where they suggested to use Git. These tutorials were an explanation for the procedure described by Will Bond, creator of the Package Control. Although it did work, but there were still some errors in it.

Recently, Will Bond has updated the package control installation procedure and now it has become really easy to install the Package Control for Sublime Text 3. 

Follow the steps below to install the Package Control (I'm assuming that you've already installed Sublime Text 3).

1. Open Sublime Text 3 and access its console by pressing CTRL + ` shortcut or going to View > Show Console menu. 


How to access the Console window

2. Paste the following code into the console and press Enter:

import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())


Paste the code into the Console

It'll take a minute or two to install all the appropriate files. And believe it or not, you've actually successfully installed the Package Control into your Sublime Text 3 text editor.

Now What?
Now that you've installed the Package Control, we can easily search for packages using the Command Palette. To open it, press the CTRL + SHIFT + P shortcut or go to Tools > Command Palette to open the Command Palette window.


How to access the Command Palette

One of the uses of the Command Palette is to search for packages that different developers have created. The screenshot below shows how the Command Palette looks like:


Command Palette Window
To search for a package, type Install Package into the Command Palette and press Enter. Remember that Sublime Text won't show this option if you don't install the Package Control first (as discussed above).


Type install package into the Command Palette

After you press the Enter key, the Command Palette will disappear for 2 to 3 seconds and it'll reappear but this time with a list of all the packages available for Sublime Text. All you need to do is type the name of your desired package and it'll be highlighted automatically.


List of Packages available for Sublime Text

As an example, I'll search for a package name AutoPrefixer. I'll type Prefix into the Command Palette and Sublime will highlight the name of the package itself. Now when I'll press Enter Sublime Text will install this package in a jiffy.


Search for the Autoprefixer package 


Conclusion
I hope that searching packages won't be a problem now for any Sublime Text user. Please let me know if you have any questions regarding this post and I'll be more than happy to answer. Thanks for reading.