Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

3 Answers 3

up vote 5 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))
    (save-buffer)
    (kill-buffer)))

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

;; EOF ;;
share|improve this answer

http://www.faqs.org/docs/Linux-HOWTO/C-C++Beautifier-HOWTO.html should cover most topics of your problem:

C++ : BCPP site is at "http://dickey.his.com/bcpp/bcpp.html" or at
      "http://www.clark.net/pub/dickey" . BCPP ftp site is at 
      "ftp://dickey.his.com/bcpp/bcpp.tar.gz"

C++ : "http://www.consultix-inc.com/c++b.html"

C : "http://www.chips.navy.mil/oasys/c/" and mirror at Oasys

C++ : "http://www.semdesigns.com/Products/DMS/DMSToolkit.html"

C++, C, Java and Oracle Pro-C Beautifier:
     "http://www.geocities.com/~starkville/main.html"

C++, C beautifier "http://users.erols.com/astronaut/vim/ccb-1.07.tar.gz" 
     and site at "http://users.erols.com/astronaut/vim/#vimlinks_src"

C++, C, Java, Perl beautifier CBP "http://www.prismtk.de/docs/cbp"

GC! GreatCode! is a powerful C/C++ source code beautifier Windows 
     95/98/NT/2000 "http://perso.club-internet.fr/cbeaudet"

CbVan for C, C++ and Java at "http://www.geocities.com/~starkville/main.html"

Artistic Style beautifier for C, C++, Java at 
     "http://sourceforge.net/projects/astyle" "http://astyle.sourceforge.net".
share|improve this answer

Your Answer

 
discard

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.