codefmt is a utility for syntax-aware code formatting. codefmt relies on codefmtlib for registration and management of formatting plugins.
For details, see the executable documentation in the vroom/
directory or the
helpfiles in the doc/
directory. The helpfiles are also available via
:help codefmt
if codefmt is installed (and helptags have been generated).
Use :FormatLines
to format a range of lines or use :FormatCode
to format
the entire buffer.
Before:
int foo(int * x) { return * x** x ; }
After running :FormatCode
:
int foo(int* x) { return *x * *x; }
This example uses Vundle, whose
plugin-adding command is Plugin
.
" Add maktaba and codefmt to the runtimepath.
" (The latter must be installed before it can be used.)
Plugin 'google/vim-maktaba'
Plugin 'google/vim-codefmtlib'
Plugin 'google/vim-codefmt'