This plugin wraps the file clang-format.py and can now be used with plugin manager tools like Vundle or vim-plug.
Why not using vim-clang-format or vim-autoformat instead of wrap a python script. Because both tools wipes the jump list, which makes the usage feel like a torment.
Install this plugin with your favorite plugin-manager or manual with the following commands:
git clone https://github.com/aufgang001/vim-clang-format-py.git ~/.vim/vim-clang-format-py.git
Your vim must support Python 3, which can be checked in vim by the commands
:version
:python3 print("test")
You have to install clang-format. For example with the command:
sudo apt-get install clang-format-3.8
Add the following line to your .vimrc file:
let g:clang_format_path = "clang-format-3.8"
Finally, bind the new command ClangFormat to a key:
noremap <F12> :ClangFormat<CR>
Mark a block of code or position the cursor to a specific line and enter your previously defined shortcut.