依賴

js-beautify的安裝:

1
2
3
npm -g install js-beautify
# 或
pip install jsbeautifier

配置快捷鍵

1
2
3
4
vmap <leader>jsb :'<,'>!js-beautify -i<CR>
autocmd FileType javascript noremap <buffer> <leader>jsb :call JsBeautify()<CR>
autocmd FileType html noremap <buffer> <leader>htmlb :call HtmlBeautify()<CR>
autocmd FileType css noremap <buffer> <leader>cssb :call CSSBeautify()<CR>