How to fix indentation in Vim scripts for jQuery?

I have this part of the script indented from Vim as follows:

$(function () { $('#fileupload').fileupload({ url: siteurl + 'ajax/upload', dataType: 'json', progress: function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); }, start: functuion (e, data) { }, 

I mean, if I select these lines and press = , this is what I get, while I would like it to look like this:

 $(function () { $('#fileupload').fileupload({ url: siteurl + 'ajax/upload', dataType: 'json', progress: function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); }, start: functuion (e, data) { }, 

I use this one. Any suggestion?

+4
source share
1 answer

I use this JavaScript indentation plugin from Ryan Fabella and it produces this (which I think is more correct than you expect):

 $(function () { $('#fileupload').fileupload({ url: siteurl + 'ajax/upload', dataType: 'json', progress: function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); }, start: functuion (e, data) { }, 
+3
source

Source: https://habr.com/ru/post/1487000/


All Articles