I solved the problem differently using a combination of bash
and vim
commands.
First, I installed clang-format
package
# apt-get install clang-format-3.5
(I choose version 3.5 but you can choose a different one)
Second, Test if clang-format
is working
$ clang-format-3.5 -style=Google test.cpp
Then, run vim
$ vim test.cpp
vim
allows to run an external command and print it's output into current buffer
:r ! clang-format-3.5 -style=Google %
(more details about external commands in vim https://www.linux.com/learn/vim-tips-working-external-commands)
This will append the output of clang-format
into current buffer. To replace current buffer, which is the desirable effect, specify the lines to output into
:%! clang-format-3.5 -style=Google %
(the first %
means all line in current file)
You can make this process more productive by defining new commands in vim (using command
) for both visual and command-line modes.
s/:pyf/:py3f/
works for me