I am trying to use clang-tools in particular clang-format for automatic code formatting in vim but I couldn't find this tool with apt-get search.
Is there anybody experienced this problem before, do you have any suggestion?
clang-format is not available in the ubuntu-precise 12.04 but it is available in ubuntu saucy http://packages.ubuntu.com/saucy/clang-format-3.4. Show activity on this post. You can check https://apt.llvm.org/ if your operating system is not on this list.
To open up a terminal window on the Ubuntu desktop, press Ctrl + Alt + T on the keyboard. Or, search for “Terminal” in the app menu. Once it is open, use the apt install command and the –install-suggests command-line switch to get Clang 11 set up, along with Ubuntu suggested packages.
You can install clang-format and git-clang-format via npm install -g clang-format . To automatically format a file according to Electron C++ code style, run clang-format -i path/to/electron/file.cc . It should work on macOS/Linux/Windows.
Standalone Tool clang-format is located in clang/tools/clang-format and can be used to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
clang-format is not available in the ubuntu-precise 12.04 but it is available in ubuntu saucy http://packages.ubuntu.com/saucy/clang-format-3.4.
in order to find this package with the apt-cache we have to add below list into our repository list. Actually below list is generated for the singapore servers but if you want to look for your own country you can use http://repogen.simplylinux.ch/generate.php
After generating your list, you have to add them into your repository, you can learn how to do that by looking to here. https://help.ubuntu.com/community/Repositories/CommandLine
The list of packages are;
deb http://sg.archive.ubuntu.com/ubuntu/ saucy main restricted universe multiverse deb-src http://sg.archive.ubuntu.com/ubuntu/ saucy main restricted universe multiverse deb http://sg.archive.ubuntu.com/ubuntu/ saucy-security main restricted universe multiverse deb http://sg.archive.ubuntu.com/ubuntu/ saucy-updates main restricted universe multiverse deb http://sg.archive.ubuntu.com/ubuntu/ saucy-proposed main restricted universe multiverse deb http://sg.archive.ubuntu.com/ubuntu/ saucy-backports main restricted universe multiverse deb-src http://sg.archive.ubuntu.com/ubuntu/ saucy-security main restricted universe multiverse deb-src http://sg.archive.ubuntu.com/ubuntu/ saucy-updates main restricted universe multiverse deb-src http://sg.archive.ubuntu.com/ubuntu/ saucy-proposed main restricted universe multiverse deb-src http://sg.archive.ubuntu.com/ubuntu/ saucy-backports main restricted universe multiverse
Then you should search clang-format with below command first
sudo apt-cache search clang-format
Then, you can install which version you want to install such as;
sudo apt-get install clang-format-3.3
With Ubuntu 16.04, simply do:
sudo apt install clang-format
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With