How can I format JS code in Vim?

前端 未结 7 1896
半阙折子戏
半阙折子戏 2020-12-14 08:19

I have this bit of JavaScript...

 15   $(\'.ajax_edit_address\').each(function() {
 16     $(this).ajaxForm({
 17       target: $(this).parents(\'table.addre         


        
7条回答
  •  难免孤独
    2020-12-14 09:02

    If you've got js-beautify installed (it's available for Python: pip install jsbeautifier, or Node: npm -g install js-beautify) then you can just run it directly from vim - to reformat the current file:

    :%!js-beautify
    

提交回复
热议问题