9

I just installed TernJS and I can get intellisense by entering ctrl+space. However, I want to get intellisense, autocomplete, options when I enter a dot after an object in JavaScript.

I tried the following without luck

"auto_complete_selector": "source, text",

I tried the suggestions in Sublime Text 2 auto completion popup does not work properly without luck

Any suggestions?

Community
  • 1
  • 1
iWarrior
  • 195
  • 1
  • 10
  • Possible dup: http://stackoverflow.com/questions/11360659/javascript-sublimecodeintel-and-hinting-code-intelligence-auto-completion – megawac Nov 19 '13 at 04:13
  • Not a duplicate, as I mentioned, I can get autocomplete - sometimes called intellisense - to work. However, my problem lies in getting the the drop down intellisense choices after entering a dot. BTW, this is a common functionality for IDEs. – iWarrior Nov 19 '13 at 04:35

1 Answers1

13

Go to Preferences -> Settings - User and add the following (remove the last comma if it's the last entry in the array):

"auto_complete": true,
"auto_complete_commit_on_tab": true,
"auto_complete_selector": "source, meta.tag", // you can make this "source - comment, meta.tag" if you don't want autocomplete in comments
"auto_complete_triggers": [
    {"selector": "text.html", "characters": "<"},
    {"selector": "source, text.html", "characters": "."}
],

and you should be all set.

BTW, "IntelliSense" is a trademark of Microsoft, in other contexts it's just called auto-complete or autocomplete.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • I can now get autocomplete using the dot after an object. However, upon closer inspection I have a new problem. The functionality works as expected in a JavaScript file (.js extension) but in an HTML file it does not. If I change the Sublime Text language from HTML to View -> Syntax -> JavaScript, then I get the expected functionality. If I leave it as HTML, then autocomplete does not recognize the object. – iWarrior Nov 20 '13 at 04:50
  • try adding `text.html` to the selector as well - see my revision above – MattDMo Nov 20 '13 at 05:28
  • OK, I got a configuration that works. I removed TernJS and installed [SublimeCodeIntel](https://sublime.wbond.net/packages/SublimeCodeIntel). I did not have to add any additional user settings. For anyone looking for JavaScript autocomplete, go with SublimeCodeIntel, it works - thanks @MattDMo. – iWarrior Nov 20 '13 at 05:30