Nice to see some Vim users here. Perhaps we could share tipsfor tuning Vim for Javascript development? I have lots of experience configuring Vim for Haskell, but have just started on configuring it for Javascript. Here are a couple that might not be obvious:
- while Vim supports tag files for code navigation, tuning the tag file generators for Javascript can be tricky, and one needsto rerun the generator occcasionally; A little known alternative is to reconfigure Vim's built-in support for include-file searches (:help include-search/ :help definition-search). This was meant for CPP style include files and finding macro definitions, but it doesn't take much to repurpose it for Javascript: similar to reconfiguring tag file generators, one needs patterns that identify interesting definitions, and since Javascript has no include files, one needs to indicate source dependencies in some way - I use comments of the form
// dependency: module.js // dependency: utils.js You might have to expand/modify the definition patterns,but once you've got them right for your coding style, you can use things like open a split window for definition of keyword under cursor (ctrl-w ctrl-d), list lines in current and included files that contain keyword under cursor (which should include other uses), list definitions for keyword under cursor (which should include var-declarations), and so on.
- somewhat more conventional: while I don't use code snippet generators for loops and the like, I do find it helpful to add JavaDoc-style comments to function definitions (this first draft can convert single-line function definitions with parameters into doc templates: with cursor on the line of the function definition, type '\/').Code is short and attached, to avoid transmission errors - it should go into 'vimfiles/after/ftplugin/javascript.vim', so that it adds to the standard javascript filetype plugins. Adapt/adopt as you like, and please share your own Vim Javascript tips!
What would be most useful: is there a way of hooking into the standard browser Javascript engines, their error messages and console features from the command line (not mock up the
environments, but reuse the actual browsers, similar to whatjs-test-driver [1] does for testing; actually, I should check: does js-test-driver capture syntax/load errors as well)?
Claus [1] http://code.google.com/p/js-test-driver/ -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
javascript.vim
Description: Binary data
