🌚

在Vim中格式化Javascript、HTML和CSS

Posted at — Feb 21, 2017
#vim #javascript #html #css #编程

依赖

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>