Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any command line tool which can be used to beautify c++ file on ubuntu? If yes, can you please suggest one?

Thank you.

share|improve this question
up vote 9 down vote accepted

Have you tried GNU indent?

share|improve this answer

astyle is quite good and in my experience does a much better as indent for C++.

When you are familiar with Emacs you can also use that for automatic indention from the command line, a simple Emacs script for that would look like this:

#!/usr/bin/emacs --script

(require 'cc-mode)

(setq require-final-newline 'visit)
(setq c-default-style "gnu")

(defun indent-files (files)
  (dolist (file files)
    (find-file file)
    (indent-region (point-min) (point-max))
    (untabify (point-min) (point-max))

(indent-files command-line-args-left)

;; EOF ;;
share|improve this answer should cover most topics of your problem:

C++ : BCPP site is at "" or at
      "" . BCPP ftp site is at 

C++ : ""

C : "" and mirror at Oasys

C++ : ""

C++, C, Java and Oracle Pro-C Beautifier:

C++, C beautifier "" 
     and site at ""

C++, C, Java, Perl beautifier CBP ""

GC! GreatCode! is a powerful C/C++ source code beautifier Windows 
     95/98/NT/2000 ""

CbVan for C, C++ and Java at ""

Artistic Style beautifier for C, C++, Java at 
     "" "".
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.