Google vim-codefmt

Google vim-codefmt

Commands

:FormatCode <TAB>

Installation

With vim-plug

vim ~/.vimrc

1
2
3
4
5
6
7
call plug#begin('~/.vim/plugged')

Plug 'google/vim-maktaba'
Plug 'google/vim-codefmt'
Plug 'google/vim-glaive'

call plug#end()

:PlugInstall

Autoformatting

vim ~/.vimrc

1
2
3
4
5
6
7
8
9
10
augroup autoformat_settings
autocmd FileType bzl AutoFormatBuffer buildifier
autocmd FileType c,cpp,proto,javascript AutoFormatBuffer clang-format
autocmd FileType dart AutoFormatBuffer dartfmt
autocmd FileType go AutoFormatBuffer gofmt
autocmd FileType gn AutoFormatBuffer gn
autocmd FileType html,css,sass,scss,less,json AutoFormatBuffer js-beautify
autocmd FileType java AutoFormatBuffer google-java-format
autocmd FileType python AutoFormatBuffer yapf
augroup END

Installing Formatters

clang-format

sudo apt install clang-format

vim ~/.vimrc

1
2
call glaive#Install()
Glaive codefmt clang_format_executable='/usr/bin/clang-format'
Author

Tracy Liu

Posted on

2019-09-06

Updated on

2021-03-31

Licensed under

Comments