Recommended Vim plugins for JavaScript coding?

Tarek Saied picture Tarek Saied · Jan 24, 2011 · Viewed 58.5k times · Source

I'm new to JS & Vim. Which plugins would help me to write Javascript code?

Answer

Ory Band picture Ory Band · May 5, 2011

Syntax Checking / Linting

There is a very easy way to integrate JSLint or the community-driven jshint.com (which is much better IMO) with Vim using the Syntastic Vim plugin. See my other post for more info.

Source-Code browsing / Tag-list

There's also a very neat way to add tag-listing using Mozilla's DoctorJS (formerly jsctags), which is also used in Cloud9 IDE's Ace online editor.

  1. Install the following packages using your favorite package-manager (Ubuntu's apt-get, Mac's home brew, etc.):
    1. exuberant-ctags
      • NOTE: After installing make sure running ctags actually runs exuberant-ctags and not the OS's preinstalled ctags. You can find out by executing ctags --version.
    2. node (Node.js)
  2. Clone DoctorJS from github: git clone https://github.com/mozilla/doctorjs.git
  3. Go inside DoctorJS dir and make install (You'll also need the make app installed, but this is very basic).
    • There're some bugs with installing the plugin, make install doesn't do the trick for the moment. For now I just add the repo's bin/ dir to my $PATH instead. See DoctorJS's GitHub and issues pages for more info.
  4. Install the TagBar Vim plugin (NOTE: It's TagBar, not the old infamous TagList!).
  5. PROFIT. :)

New Project - Tern.js

DoctorJS is currently dead. There's a new promising project called tern.js. It's currently in early beta, and should eventually replace it.

There is a project ramitos/jsctags which uses tern as its engine. Just npm install -g it, and tagbar will automatically use it for javascript files.