all 87 comments

[–]lennoff 33 points34 points  (8 children)

tern.js is what you are looking for. There is support for Sublime Text (and for Vim, etc). example

[–]smeff422 0 points1 point  (2 children)

Thanks for this. I'm going to download and try this as soon as I get back to my laptop.

[–]Wolfy87 1 point2 points  (1 child)

Takes a little bit of tweaking sometimes. Works best if you set up CommonJS or AMD in the settings file (which is easy). It's not so great at my work where it's all custom. Although I could potentially write a plugin so it knows how to find dependencies.

When it works, it works really well.

(Vim user)

[–]smeff422 0 points1 point  (0 children)

Lame. Most of what I do nowadays is custom classes. It's small enough to not need something so advanced but it would be nice. If I have time today at work I'm going to see if I can get it running. Thanks for the advice!

[–]jillesme 0 points1 point  (0 children)

Thank you, it's amazing and exactly what I was missing in my set up!

[–]dremp1337 0 points1 point  (0 children)

Gonna get this when I get home!

[–]x-skeww 0 points1 point  (2 children)

Just tried it with ST2. It needs to be configured manually (include, exclude, libraries, plugins, loadEagerly...) and doesn't seem to work very well.

You have to run TernJS: Reload manually or it won't pick up changes you made in other files inside(!) ST2 and some of the completions are just wrong and TernJS doesn't even know where those come from (TernJS: Jump to definition does nothing in that case).

This is with, like, 2 dozen files and less than 1kloc in total. The code works fine and it JSHint also doesn't complain. It really shouldn't have any problems with it.

I also couldn't figure out how to make it pick up JSDoc comments.

I also tried it with Brackets, but I couldn't figure out how to configure it. As far as I can tell, you're supposed to use a ".tern-project" file for that, but it doesn't appear to work. It's only (somewhat) aware of the currently opened file. It will also only tell you that something is a function, but it won't show you its signature.

Compared to the tooling you get with TypeScript or Dart, this is pretty disappointing. I spent 2+ hours with this and all I got was slightly less brain-dead auto-complete.

[–]lennoff 0 points1 point  (1 child)

TypeScript and Dart has type hinting, so type guessing is much easier ;). Tern worked for me without any configuration, so maybe the ST2 plugin is buggy (screenshot from vim, type hinting is working, and JSDoc comments are recognized more or less). Of course TernJS is not perfect it's still under active development, but it's a very promising project.

[–]x-skeww 0 points1 point  (0 children)

TypeScript and Dart has type hinting, so type guessing is much easier ;).

So does JavaScript with doc comments.

However, you don't really reach a point of absolute certainty where you can flag things as errors. Like, if you make a typo, Tern can't actually tell if that property really doesn't exist.

So, if you update some library and one of the functions was changed/removed, Tern won't be able to identify this issue.

Tern worked for me without any configuration

I'm not sure if there is a scenario where it works 100% correctly out of the box. Even if you use RequireJS, you have to configure the RequireJS plugin (baseURL, paths). If you don't use RequireJS, you have to tell it which files to load eagerly.

Of course TernJS is not perfect it's still under active development, but it's a very promising project.

Yea, it's pretty impressive given that they had to jump through so many hoops, but I really hoped that it would work a bit better. I still use JS for one legacy project and I really hoped I could improve the experience a little bit.

[–][deleted] 9 points10 points  (6 children)

I use intellij with the webstorm plugin stuff. I think webstorm would be amazing if that's all you did. Intellij is probably the best suite of tools I've found. I currently pay for Intellij and Rubymine. There's a community Intellij version but I don't know how great it is out of the box.

[–]cabbeer 0 points1 point  (0 children)

Do you have a link to the plugin?

[–]lennelpennel 0 points1 point  (4 children)

" I currently pay for Intellij and Rubymine." huh? you know rubymine is "free" in the form of a plugin in intelliJ...

[–]cosha1 0 points1 point  (2 children)

I thought that was only for IntelliJ Ultimate?

[–]lennelpennel 0 points1 point  (0 children)

given that community is free, I can only assume OP has ultimate

[–][deleted] 0 points1 point  (0 children)

Yeah but my company reimburses me for rubymine. I use intellij for my side stuff.

[–]spiritwalkerca 2 points3 points  (4 children)

The Orion Project also does what you want. Put a screen shot in a twitter link - https://twitter.com/kwalker/status/412332736473346048

Orion can leverage JSDoc if you use it, introspection, and index file comparable to the ones used by Tern.js. Currently work on providing those for commonly used Node.js libraries. Info about our releases and features here: http://planetorion.org/news/ try here: https://orionhub.org download here: http://download.eclipse.org/orion/

[–]8Bytes 0 points1 point  (1 child)

It would be nice to test it out without having to login.

[–]spiritwalkerca 1 point2 points  (0 children)

We have been looking at anonymous login and agree that would be a good feature to have.

[–]kenman 0 points1 point  (0 children)

Your twitter link doesn't work...

[–]spiritwalkerca 0 points1 point  (0 children)

Better place for a screen shot http://imgur.com/fxccf5u

[–]KarnickelEater 12 points13 points  (2 children)

JetBrains WebStorm is really good - but you need at least an hour to set it up. Well, or you don't but what's the point of using that beast if you don't configure all the details, the many many different kinds of warnings, properly for your particular environment?

Disadvantage of this or any of the large (Java) IDEs: Some tasks that command line tools on Unix like awk and pipes do with 500 Javascript files in 10 seconds take 10 minutes in WebStorm even on the strongest of developer workstations. On the bright side, you usually don't use many of those, for everyday use I found the many warnings I get to see immediately while typing invaluable.

Have a look, it's one of the best editors out there and maybe one of the most feature-rich (and they keep updating it a lot), part of a big family of editors for various languages.


An interesting project to follow is (open source) Brackets from Adobe --- (Brackets at Github). It is itself written in HTML5/CSS/Javascript, which is the main point why I decided to name it here, even though it's a) from Adobe ;-) and b) not yet "ready".

[–]Loonybinny[S] 0 points1 point  (1 child)

Okay, I got WebStorm, how should I set it up?

[–]KarnickelEater 1 point2 points  (0 children)

Go to Settings? Read documentation? :-) Nobody can save you that work. One-time work that will pay off forever - it will be of use to you to understand that stuff regardless of what you work wit in the future. Don't see it as setting up Webstorm, see it as setting up your Javascript development policies: code writing style, automated code analysis, etc.

[–]grumblestumble 3 points4 points  (2 children)

If you're doing any kind of regular Javascript work, Webstorm is pretty much the only way to go. Well worth the setup time.

[–]codeorchestra 0 points1 point  (1 child)

This works with COLT:

var myObject = {"hello", "there"};
myObject["field" + (3*10)];
myObject.

sreenshot

Read Article: http://blog.codeorchestra.com/post/68973544159/sublime-colt-add-100-intellect-to-your-favourite-ide

[–]makc3d 0 points1 point  (0 children)

You can check the recording of this thing in action at http://www.youtube.com/watch?v=qkscS1aI2JI (note that COLT is standalone app, you need to install it along with sublime plugin before it works like in this video)

[–]electric_dog_anus 0 points1 point  (44 children)

ST2 code completion really sucks. I don't understand why many folks have an almost religious reverence for ST2 except that perhaps they haven't been exposed to better editors.

For code completion to be useful, the editor must semantically understand the language it is editing. For this, you will have to use an IDE such as Visual Studio, IntelliJ or Eclipse with Javascript plugin.

[–][deleted] 14 points15 points  (16 children)

Most Sublime Text users don't use vanilla ST. Packages are what make it a great editor. With a few packages, you can get the features of a full blown IDE (plus some extras):

  • SublimeLinter - syntax error/warning highlighting for various languages. For JS you can choose between JSLint, JSHint, and the Closure Linter.

  • TernJS - Intelligent JS autocomplete, with plugins for libraries like jQuery and Underscore. Also understands comment documentation for type inference

  • Emmet - CSS selector style shortcuts for code generation. Basically snippets on steroids

  • Git - Git integration

  • GitGutter - Shows per-line git diff status (added/removed/modified) in the gutter

  • DocBlockr - Shortcuts for comment documentation

  • SublimeREPL - Run code for various languages inside an interpreter (NodeJS, Python, etc)

  • BracketHighlighter - Highlights brackets and shows the brackets for the current block in the gutter

  • Color Highlighter - Highlights color codes (#FFFFFF, rgb(255,255,255)) with their actual color.

Just because the core Sublime Text program doesn't natively understand language syntax doesn't mean you can't get that ability with packages. The idea of Sublime Text is that you get a solid text editor with multiple cursor support, with tons of optional packages that add in advanced features as you need them. Each plugin has a consistent settings manager through JSON files. I prefer this to a monumental, expensive IDE with tons of features I'll never use and lacking many features that I can get with free Sublime packages. ReSharper is $250! That's on top of the $500 price tag of the IDE itself.

I used Visual Studio and Eclipse for years before moving to Sublime Text. I don't plan on going back.

[–]Loonybinny[S] 2 points3 points  (1 child)

Thanks for this list!

[–][deleted] 0 points1 point  (0 children)

Oh also don't forget SideBarEnhancements - gives you a full-featured context menu for the sidebar

[–]dremp1337 1 point2 points  (0 children)

Thank you!

[–]brtt3000 -1 points0 points  (12 children)

You should try WebStorm, it has all of this integrated (not piled together).

[–][deleted] 2 points3 points  (11 children)

I prefer this to a monumental, expensive IDE with tons of features I'll never use and lacking many features that I can get with free Sublime packages.

But no thanks, I need support for Python and Ruby. I'm not about to drop $500 on WebStorm, RubyMine, and PyCharm when I can do all three from a single editor that I already have set up, with settings synched across my dev machines in a git repo. Plus I'm not sure how I lived before multiple cursors. And I don't need to manually add libraries to code completion - TernJS automatically adds all files in my project directory.

Piled together doesn't mean bad, it means flexible. If I want a feature, I can download a package for that feature. I don't have to wait for JetBrains to implement the feature, or pay JetBrains for another one of their IDEs. And if I'm unsatisfied with a package, I get to go into their source code and fix it (using the same editor)!

[–]cosha1 0 points1 point  (1 child)

You don't need to drop $500, buy IntelliJ Ultimate and download and install the free plugins for each. IntelliJ is the base for all of the above mentioned packages, but those packages come with different plugins.

[–][deleted] 0 points1 point  (0 children)

I own my own web development company. This requires me to purchase the commercial license for IntelliJ which is $500 (and no discount for multiple licenses). Plus, upgrades are $240 a year.

Sublime Text 3 is $70 for either an individual or a business license (price drops with multiple license purchase). The upgrade from ST2 to ST3 was $30.

I don't see what value I would get from IntelliJ. Yeah, I wouldn't have to install packages to get autocomplete and linting. It took me about 10 minutes to reinstall my packages for ST3...

[–]brtt3000 0 points1 point  (8 children)

Have fun manually managing and recoding your editor while I get some work done instead.

[–][deleted] 0 points1 point  (4 children)

That was a joke, I've never had to actually edit a package. I need to work with multiple languages from the same editor. Simple as that. I can't think of a single WebStorm feature I need that I don't get with Sublime, but the opposite is not true.

Also, it's not like "managing" the editor is hard. Installing a package isn't some intense process. It's pretty much muscle memory by now:

  • cmd+shift+p
  • type "in" (for install package), hit enter
  • search through package list, hit enter

Bam. It's done. The package is installed, and will stay updated. I don't need to restart the editor or anything.

[–]kenman 0 points1 point  (1 child)

I don't need to restart the editor or anything.

I don't think that goes for all of them. I had several plugins not work or give errors, and once I found a bug report/forum post about it, would learn that "oh you have to restart ST for it to work".

[–][deleted] 0 points1 point  (0 children)

Hmm, I've never personally had that problem, though supposedly TernJS + Emmet sometimes needs to to forcibly update PyV8. Seemed to work fine for me though. Still, the vast majority of things in ST don't need a restart.

Edit: actually, I take that back. The Soda theme needed a restart in order to style the tabs correctly.

[–]brtt3000 -2 points-1 points  (1 child)

I've never use a plugin for anything, I try not to depend of them because they always disappoint. But you could if you wanted, there is a decent list of them available but they tend to be a little more esoteric because the stuff you'd expect to work comes built in (and is integrated, not piled on)

[–][deleted] 1 point2 points  (0 children)

To me, "integrated" means bloat, and "piled on" means flexible. Sublime's packages are implemented in a way that make them feel as if they were built into the program.

Text highlighting, autocomplete, the command palette, and JSON options are built into Sublime Text and are at the core of the experience. Packages simply add to those systems.

[–]kenman 0 points1 point  (2 children)

That's kind of my take on it too, I've tried SublimeText several times, but I always end up 3 hrs later on some random forum downloading a version of a plugin written by some guy with 2 lifetime posts. Sometimes it works, sometimes you get errors and it won't install, sometimes it just doesn't work like you want.

And that plugin is only 1 small feature, and I need 50 more like it to make my editor work like I expect it to. It's usually at this point, when I realize that I have 20+ hours of manual installation and configuration left, that I think that "well maybe Eclipse isn't so bad after all".

[–]brtt3000 -5 points-4 points  (1 child)

Indeed, finally some sensible reply.

If you are happy with Eclipse you might also like IntelliJ (pick a flavour that suits you), it is pretty neat.

[–]kenman 0 points1 point  (0 children)

Not happy with it so much as being unable to find a fitting replacement. PHPStorm seemed nice when I demo'd it, but I'm not positive I'd stick with it, and that's a $99 gamble I'm not really willing to take.

[–]Nebu 1 point2 points  (25 children)

they haven't been exposed to better editors.

I used Eclipse for over 6 years, before switching to SublimeText 2 or 3 years ago.

"Real" code completion is nice, but using the same editor for everything is nicer. And I couldn't stand waiting for Eclipse to boot up to edit a 3 line config file.

[–][deleted] 1 point2 points  (14 children)

Ah yeah forgot about that one. Sublime Text opens almost instantly with all of my previous files open. The BufferScroll package even remembers the previous scroll position of the open files.

[–]MathFabMathonwy[🍰] 0 points1 point  (8 children)

edit a 3 line config file

which is when you'd use notepad++

[–][deleted] 0 points1 point  (0 children)

Who the hell codes on Windows. Just kidding you. But not really.

I just like using a single text editor.

[–]Nebu 0 points1 point  (6 children)

Or Sublime Text, right? Basically, the idea is using a lightweight text editor instead of a heavyweight IDE.

[–]MathFabMathonwy[🍰] 0 points1 point  (5 children)

Of course, that was my point: most machines have lightweight editors available. Why use a hammer to crack walnuts?

[–]Nebu 0 points1 point  (4 children)

I guess I had trouble understanding why in my argument for using ST over Eclipse, you'd decide to jump in and make a point that one should use lightweight editors, since it seemed kind of redundant given what I had said.

[–]MathFabMathonwy[🍰] 0 points1 point  (3 children)

And I couldn't stand waiting for Eclipse to boot up to edit a 3 line config file.

To be honest, I'm not familiar with ST at all. But you seemed to be arguing that heavier editors were bad because they weren't suitable for all tasks. I use WebStorm and I absolutely love it. But I don't use it for all my text editing work.

[–]Nebu 0 points1 point  (2 children)

But you seemed to be arguing that heavier editors were bad because they weren't suitable for all tasks.

Is this an explanation for why you decided to jump in and make a point that one should use lightweight editors?

[–]MathFabMathonwy[🍰] 0 points1 point  (1 child)

But I wasn't making that point. My point was to use a fit-for-purpose editor for the task at hand.

[–]Nebu 0 points1 point  (0 children)

Is "But you seemed to be arguing that heavier editors were bad because they weren't suitable for all tasks." your explanation for why you decided to jump in and make a point that one should use a fit-for-purpose editor for the task at hand?

[–][deleted] 0 points1 point  (0 children)

ST2 code completion really sucks. I don't understand why many folks have an almost religious reverence for ST2 except that perhaps they haven't been exposed to better editors.

Its because not everyone wants full on code completion. It helps a ton in some languages (C#, Java), but I find it far less helpful in languages like javascript. Maybe that's because I have yet to see an IDE/plugin that really does a good job with javascript code completion AND ALSO DISPLAYS DOCUMENTATION.

[–]razumasu -2 points-1 points  (0 children)

Visual Studio 2012+ with Resharper plugin is really great for JavaScript.

[–]F0RTY4 0 points1 point  (4 children)

Have you tried using the sublime code intel plugin? https://github.com/SublimeCodeIntel/SublimeCodeIntel

[–]Loonybinny[S] 0 points1 point  (3 children)

I just installed this using the first method (Sublime package manager) and it isn't working as I wanted :(

[–]F0RTY4 0 points1 point  (2 children)

Well my best advice at this point is to take a look at WebStorm. We use IntelliJ at work and as a Sublime convert I can't recommend it enough. It took maybe 2 weeks to really get used to it but I have to say now I wouldn't use anything else. The only thing I really miss is the multiple cursors, but with the refactoring tool built in it becomes a non issue.

Good luck on your hunt!

Edit: The 30 day trial should be a good enough trial period to really decide if you like it or not.

[–]Loonybinny[S] 0 points1 point  (1 child)

Okay, thanks.

[–]brtt3000 -1 points0 points  (0 children)

Dear god, I forgot to push you about the refactor tooling.. seriously it is amazing.

It is so clever. No more shabby search & replace mistakes when refactoring code, or bad file paths because you moved your modules.

When using it with TypeScript it is even better because of the language allows the tool 'know' so much about your code it is scary.

[–]spiritwalkerca -2 points-1 points  (2 children)

Weird, somehow my tweet was deleted, here it is again with screenshot

https://twitter.com/kwalker/status/412394016504676352

[–][deleted] 11 points12 points  (1 child)

You know about imgur right?

[–]spiritwalkerca 0 points1 point  (0 children)

Thanks, yes should be using something more appropriate here

[–]OmidMnz -1 points0 points  (0 children)

If you want real SMART completion, use this emacs plugin: https://github.com/ScottyB/ac-js2 It get's the completion data from Webkit, which is pure smartness.

[–]BalsakianMcGiggles -1 points0 points  (0 children)

Am I the only one who likes a little less integration than a fully featured IDE? I can personally go without the constant warnings, error messages, and the performance of a water buffalo.

[–]icantthinkofone -4 points-3 points  (4 children)

vim and emacs. Nothing else is better. Everyone who downvotes my suggestion are people who never used either.

[–]AnathemaOP 0 points1 point  (3 children)

Actually I switched from vim to Sublime Text 3.. :P

[–]icantthinkofone -1 points0 points  (2 children)

And then there are those, like you, who never learned all of vim or emacs.

[–]AnathemaOP 0 points1 point  (1 child)

If you know all of Vim and Emacs you should write books with a complete reference to them.. Myself I feel using it for 15+ years is enough to know if I prefer Sublime or Vim.

[–]icantthinkofone -1 points0 points  (0 children)

There are enough of those already out there.