I’m new to JS & Vim. Which plugins would help me to write Javascript code?
Advertisement
Answer
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.
- Install the following packages using your favorite package-manager (Ubuntu’s
apt-get, Mac’s homebrew, etc.):exuberant-ctags
- NOTE: After installing make sure running
ctagsactually runsexuberant-ctagsand not the OS’s preinstalledctags. You can find out by executingctags --version. 2.node(Node.js)
- Clone
DoctorJSfrom github:git clone https://github.com/mozilla/doctorjs.git - Go inside
DoctorJSdir andmake install(You’ll also need themakeapp installed, but this is very basic).
- There’re some bugs with installing the plugin,
make installdoesn’t do the trick for the moment. For now I just add the repo’sbin/dir to my $PATH instead. See DoctorJS’s GitHub and issues pages for more info.
- Install the TagBar Vim plugin (NOTE: It’s TagBar, not the old infamous TagList!).
- 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.