This post describes how to configure Sublime Text in order to get statement completion for JavaScript, Python, (and perhaps PHP, RHTML, Smarty, Mason, Node.js, XBL, Tcl, HTML, HTML5, TemplateToolkit, XUL, Django, Perl, and Ruby).

After following the steps, statement completion will also work for Python projects installed in a virtualenv.

  • Download Sublime Text from here.
  • Install on Windows or OS X (it doesn’t really matter).

Install Package Manager

  • Run Sublime Text
  • Open the Sublime Text Console. This is accessed via the ctrl + ` shortcut.
  • Paste the command found here into the console.
  • Restart Sublime Text

We have just installed Sublime Package Control - A full-featured package manager that helps discovering, installing, updating and removing packages for Sublime Text 2. It features an automatic updater and supports GitHub, BitBucket and a full channel/repository system.

Configure Statement Completion

  • Press ctrl + shift + p (Windows, Linux) or cmd + shift + p (OS X).
  • Type Install Package and select it.

The Install Package command shows a list of all available packages that are available for install. This will include all of the packages from the [default channel](http://wbond.net/sublime_packages/community), plus any from repositories you have added.

  • Select SublimeCodeIntel from the list of packages.

Configure Statement Completion for Python projects in virtualenv

You may skip this if you are not using virtualenv.

  • Create a .codeintel directory at the root of the project
  • Create a config file (without any extension) inside the newly created directory.
{
    "Python": {
        "python": '~/Documents/Projects/VirtualEnvName/bin/python',
        "pythonExtraPaths": ['~/Documents/Projects/VirtualEnvName/lib/python/site-packages',
        ]
    },
}

Note that VirtualEnvName is the name of the virtualenv were the files of the project are located.

The project itself is in ~/Documents/Projects/VirtualEnvName/ProjectName

Statement Completion in action

A screenshot for jQuery (note also the very cool theme)

A screenshot for jQuery

Also,

A screenshot for Document Object Model

A screenshot for Python

References: