sponsor Vim development Vim logo Vim Book Ad

JavaScript syntax : Better JavaScrirpt syntax support

 script karma  Rating 1610/571, Downloaded by 44524  Comments, bugs, improvements  Vim wiki

created by
Yi Zhao
 
script type
syntax
 
description
Hi JavaScript and VIM funs,

If you want to use VIM to edit/view the JavaScript files, you should have this one.
Replace it with the javascript syntax file included with the VIMRUNTIME.

Why it is here:
Because I found that the originaly one which packed with the VIMRUNTIME didn't work very well for the JS files in Mozilla Browser/SeaMonkey/Firefox and Dojo. So I decided to some refine on it.

Hope it is also useful for you~~~

Good Luck,

Yi Zhao (ZHAOYI)
Blog: http://linuxyz.blogspot.com/
 
install details
M$ Windows: put at $VIMRUNTIME/syntax/javascript.vim
or
Unix: put it at ~/.vim/syntax/javascript.vim
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
javascript.vim 0.7.7 2009-06-04 6.0 Yi Zhao Add "undefined" as a type keyword
javascript.vim 0.7.6 2008-09-09 6.0 Yi Zhao Change the 'syntax sync' method to improve the performance with large JavaScript files.
The old way 'syntax sync fromstart' is too slow to handle the files greater than 2000 lines.
javascript.vim 0.7.5 2007-05-17 6.0 Yi Zhao 1, Get the vimdiff problem fixed finally.
  Matthew Gallant reported the problem and test the fix. ;)

2, Follow the suggestioin from Ingo Karkat.
  The 'foldtext' and 'foldlevel' settings should only be changed if the file being edited is pure JavaScript, not if JavaScript syntax is embedded inside other syntaxes.

3, Remove function FT_JavaScriptDoc(). Since VIM do the better than me.
javascript.vim 0.7.4 2007-05-14 6.0 Yi Zhao 1, Fix a bug reported by Matthew Gallant.
   It will cause the vimdiff (6.x) freezes (chokes, with a 100% cpu usage) and never finally displays the diff between the files. The script need to be finished by press CTRL+C.

2, Add some more JSDoc tags which used by Yahoo! UI

javascript.vim 0.7.3 2007-03-13 6.0 Yi Zhao Add the keywords for JavaScript 1.7: let, yield,
javascript.vim 0.7.2 2007-01-30 6.0 Yi Zhao Turn off the DOM2, HTML, and CSS speicified attributes and methods by default.

if you like it please add follow code into your .vimrc file.
let javascript_enable_domhtmlcss=1

I really hate the inaccuracy syntax highlight.

Thanks,

ZHAOYI  


javascript.vim 0.7.1 2007-01-05 6.0 Yi Zhao 1, Add DOM2, HTML, and CSS speicified attributes and methods, based on  
http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
    http://www.dannyg.com/ref/jsquickref.html
    Thanks Claudio Fleiner <claudio@fleiner.com> for the great idea.
2, Minor bug fix for JSDoc.
3, Minor bug fix for comment highlight.

NOTE:
  The syntax detection for DOM/HTML/CSS options are tricky, it can't be handled 100%  
accuracy by using the regex  based highlight system.
  If the DOM/HTML/CSS highlight make you unhappy, you can simply add these:

let javascript_ignore_domhtmlcss=1

  into your .vimrc file to prevent the highlight on DOM/HTML/CSS functions and attributes.

Thanks,

Yi
javascript.vim 0.7.0 2006-11-17 6.0 Yi Zhao Add all keywords/exceptions defined in ECMAScript Language Specification Edition 3.
javascript.vim 0.6.9 2006-11-01 6.0 Yi Zhao 1, Fix a bug of javaScriptLineComment which mark the code line which follows the indent empty // as comment.
2, Modify the javaScriptLinecomment folding mode, line comments only fold start the full line comment.
javascript.vim 0.6.8 2006-10-29 6.0 Yi Zhao Fix the function FT_JavaScriptDoc() redefine warning when switch the buffer in multi-buffer mode.
javascript.vim 0.6.7 2006-10-25 6.0 Yi Zhao 1. JSDoc parameter do recogonize "#.:/" at any position.
2. The "$" can appear at any position of the function name.
3. The continous line comments will be folding in fold mode.
javascript.vim 0.6.6 2006-10-22 6.0 Yi Zhao 1. Rename the syntax group name to javaScript* to follow the syntax file recommendation.
2, The unmached "[]", "()", and "{}" can be detected.
3, A minor bug fix for the javaScriptNumber highlight.
javascript.vim 0.6.5 2006-10-21 6.0 Yi Zhao 1, Add the highlight for Float number
2, Refine the highlight of Number  

3, Define the highlight for the JSDoc tags' value.
    e.g. "@see #see_what" the #see_what will be highlighted.

4, Fold support for JavaScript comment and Function's body
    Folding is  intesting. @see http://vimdoc.sourceforge.net/htmldoc/usr_28.html
    By default, the fold is off.

    In the Normal mode, zM to fold all.


javascript.vim 0.6 2006-10-17 6.0 Yi Zhao Add JSDoc support to the syntax file. The "@zzzz" and {@zzz xxxx} will be highlight.

For more information about the JSDoc, refer to http://jsdoc.sf.net
javascript.vim 0.5.2 2006-10-14 6.0 Yi Zhao In ECMA-262v3, The dollar sign ($) is permitted anywhere in an identifier. The dollar sign is intended for use only in mechanically generated code.  

Add dollar sigh as keyword to avoid irregular highlight against the $break or $continue

Thanks "Nai chao Wu" <superwunc AT hotmail.com> for his help.
javascript.vim 0.5.1 2006-07-02 6.0 Yi Zhao Minor upate on the jsRegexpString.
javascript.vim 0.5 2006-03-20 6.0 Yi Zhao 1, Provided the htmlJavaScript cluster to HTML syntax (syntax/html.vim).
2, Try the fold on JavaScript, I found it is really abnormal, and useless for JavaScript. So I just remove the fold from the TODO list.

And there is a syntax highlight problem in html.vim
If you want to make the JavaScript inside HTML highlight properly, please commented out the follows lines in html.vim.
<pre>
" HtmlHiLink javaScript     Special
" HtmlHiLink javaScriptExpression   javaScript
</pre>
javascript.vim 0.4.1 2006-03-18 6.0 Yi Zhao Minor fix with jsLabel and jsRegexpString.

The dojo.js and dojo.js.uncompressed.js can be highlight properly.
javascript.vim 0.4 2006-03-17 6.0 Yi Zhao 1, Update the jsRegexpString, make it work with Dojo JavaScript source.
2, Update the jsSpecial, make it match the oct/hex/unicode characters.

If you are playing with the regexp string, try this version. :)
javascript.vim 0.3 2006-03-12 6.0 Yi Zhao 1, Add jsLabel support;
2, Add all JavaScript keywords and Global Objects based on the JavaScript 1.5 reference at http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference
3, Add jsBlock can be put in jsBracket .
javascript.vim 0.2 2006-03-09 6.0 Yi Zhao Changed the file format to Unix.

I found that the DOS format file has problems to work under the Unix.
Yestorday I didn't test it under the UNIX.

I am sorry, if it caused some problem.

Thanks,

Yi Zhao
ip used for rating: 3.85.85.246

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github