Getting full JS autocompletion under Sublime Text
JavascriptSublimetext2Javascript Problem Overview
I just installed the Sublime Text under Windows Vista, and even following the advice given in this post, namely to explicitly set View > Syntax > JavaScript > JavaScript
, I only see suggestions based on what I have previously typed. I even installed the SublimeCodeIntel plug-in, to no avail.
As I understand it, the moment I write "pars" I should get the "parseFloat" and "parseInt" options, as in the Chrome developer tools, right?
Thanks!
Javascript Solutions
Solution 1 - Javascript
Suggestions are (basically) based on the text in the current open file and any snippets or completions you have defined (ref). If you want more text suggestions, I'd recommend:
- Adding your own snippets for commonly used operations.
- Adding your own completions for common words.
- Adding other people's snippets through Package Control.
- You can find even more snippets on github.
- Use Zen coding (available through Package Control) or Emmet.
- There are also various packages that adjust the way code completion works. I love SublimeCodeIntel, but check out other answers to this question for more options.
As a side note, I'd really recommend installing Package control to take full advantage of the Sublime community. Some of the options above use Package control. I'd also highly recommend the tutsplus Sublime tutorial videos, which include all sorts of information about improving your efficiency when using Sublime.
Solution 2 - Javascript
Ternjs is a new alternative for getting JS autocompletion. http://ternjs.net/
Sublime Plugin
The most well-maintained Tern plugin for Sublime Text is called 'tern_for_sublime'
There is also an older plugin called 'TernJS'. It is unmaintained and contains several performance related bugs, that cause Sublime Text to crash, so avoid that.
Solution 3 - Javascript
As already mentioned, tern.js is a new and promising project with plugins for Sublime Text, Vim and Emacs. I´ve been using TernJS for Sublime for a while and the suggestions I get are way better than the standard ones:
Tern scans all .js files in your project. You can get support for DOM, nodejs, jQuery, and more by adding "libs" in your .sublime-project file:
"ternjs": {
"exclude": ["wordpress/**", "node_modules/**"],
"libs": ["browser", "jquery"],
"plugins": {
"requirejs": {
"baseURL": "./js"
}
}
}
Solution 4 - Javascript
There are three approaches
-
Use SublimeCodeIntel plug-in
-
Use CTags plug-in
-
Generate .sublime-completion file manually
Approaches are described in detail in this blog post (of mine): http://opensourcehacker.com/2013/03/04/javascript-autocompletions-and-having-one-for-sublime-text-2/
Solution 5 - Javascript
I developed a new plugin called JavaScript Enhancements, that you can find on Package Control. It uses Flow (javascript static type checker from Facebook) under the hood.
Furthermore, it offers smart javascript autocomplete (compared to my other plugin JavaScript Completions), real-time errors, code refactoring and also a lot of features about creating, developing and managing javascript projects.
See the Wiki to know all the features that it offers!
An introduction to this plugin could be found in this css-tricks.com article: Turn Sublime Text 3 into a JavaScript IDE
Just some quick screenshots:
Solution 6 - Javascript
As of today (November 2019), Microsoft's TypeScript plugin does what the OP required: https://packagecontrol.io/packages/TypeScript.
Solution 7 - Javascript
Check if the snippets have <tabTrigger>
attributes that start with special characters. If they do, they won't show up in the autocomplete box. This is currently a problem on Windows with the available jQuery plugins.
See my answer on this thread for more details.