I find that clang-format
works well.
There are some example keybindings in the clang documentation
I prefer to use the equalprg
binding in vim. This allows you to invoke clang-format
with G=gg
or other =
indent options.
Just put the following in your .vimrc file:
autocmd FileType c,cpp setlocal equalprg=clang-format