vimclangcode-formattingclang-format

How can I install clang-format in Ubuntu?


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?


Solution

  • 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