Ubuntu – Vim-clang-format: clang-format is not found

clangvimvim-plugin

I installed clang-format on Ubuntu 18.04 LTS with sudo apt install clang-format and the installation was successful. I can execute clang-format-6.0 now, but when I use ClangFormat in vim, it tells me that "clang-format is not found". How can I fix the problem?

Best Answer

If you check what is contained in the package clang-format-6.0 (dpkg -L clang-format-6.0) you will find that it does not install clang-format into the /usr/bin directory. But you will find that it does install it to /usr/lib/llvm-6.0/bin instead.

One possible solution would be to add /usr/lib/llvm-6.0/bin to your PATH variable. Under this path clang-format is available. The command /usr/bin/clang-format-6.0 is just a symbolic link to it, so it should be equivalent to using clang-format-6.0. Why the package maintainer decided to not link /usr/bin/clang-format as well is not clear to me.

If you are unsure how to do that you may want to look it up here: https://help.ubuntu.com/community/EnvironmentVariables