Remove extra commas from javascript code

    When you write on js, situations often arise, here and there, there are lines of the form ",)" or ",}" or ",]". In ff, chrome code with such fragments works, but in IE it doesn't.

    The cure for vima: The

    autocmd BufWritePre *.js :%s/\(.*\),\(\s*\n*\s*\)\(\}\|\]\|)\)/\1\2\3/e

    regular is written on the knee, but it works and fixes most problems with commas by code.

    Add-ons are welcome!

    UPD:

    Although this approach fixes most ordinary cases, it can also ruin the code with regular lines or, for example, lines: it will turn into: If your code has regular lines and / or lines with similar constructions, then it is better to use jslint for validation. For wim, you can use github.com/hallettj/jslint.vim

    var a = "[,]";
    var a = /[,]/;




    var a = "[]";
    var a = /[]/;



    Also popular now: