AngryHacker
AngryHacker

Reputation: 61606

How to get jQuery code completion to work in Sublime Text 2?

I am doing some light jQuery based Javascript programming with Sublime Text 2. Is there such a thing as code completion for jQuery? I've installed SublimeCodeIntel, but getting nothing.

For instance, consider the following:

<div id="container">hello</div>

<script type="text/javascript">
function doStuff() {
    $('#container').html('change it');
}
</script>

When I type $('#container'). I would expect a popup with things like html, val, etc... to popup. Has anyone gotten jQuery intellisense to work at all?

P.S. To be sure, I am not trying to get snippets working, but rather code completion.

Upvotes: 3

Views: 21070

Answers (4)

Rajesh Paul
Rajesh Paul

Reputation: 7019

Try package installer in sublime

search for jquery and install.

Upvotes: 5

MattDMo
MattDMo

Reputation: 102852

SublimeCodeIntel should work just fine with jQuery, you just need to tell it where to find it. Check out the docs on configuring search paths - basically, you create a ~/.codeintel/config file, and put something like

{
    "JavaScript": {
        "javascriptExtraPaths": ["/path/to/jquery.not-minified.js"]
    }
}

in it. Remember to not use the minified version of jQuery, as some of the variable names can be changed (I think, don't hold me to it for v2). You also don't have the inline documentation. This file can also be created as /path/to/project_root/.codeintel/config if you're using different versions, different plugins, etc. Remember that SublimeCodeIntel can take a little while to index everything, so be patient the first time it runs. I've found it helpful to restart Sublime after indexing is done, just so everything is freshly loaded.

Upvotes: 4

Andy G
Andy G

Reputation: 19367

If you have installed a jQuery syntax-file (there is one available from the link provided by Srikanth AD) then my AndyJS2 add-in is available via PackageControl.

AndyJS2 provides completions for both JavaScript and jQuery - use the syntax options by clicking the bottom-right of the ST window to switch between JavaScript and jQuery.

I doubt that it would work well, though, in parallel with SublimeCodeIntel. You can disable this Package, without having to uninstall it, from the Preferences menu, Package Control

Upvotes: 1

Srikanth AD
Srikanth AD

Reputation: 1854

This jQuery package for Sublime text might help https://github.com/mrmartineau/Jquery

Upvotes: 1

Related Questions