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.

link|improve this question

62% accept rate
feedback

3 Answers

up vote 4 down vote accepted

Have you tried GNU indent?

link|improve this answer
feedback

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 ;;
link|improve this answer
feedback

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".
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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