WSU logo


College of Engineering & CS
Wright State University
Dayton, Ohio 45435-0001

CEG 333: Introduction to Unix

Prabhaker Mateti

indent


Syntax: indent OPTION... FILE...

The indent command alters the placement of delimiters and whitespace to make stylistic changes to source code files.

As indent has many different options, some of which are may vary from system to system, it is best to consult man indent and search for the specific option desired. (Remember than in man, the slash key, "/", starts a search.)

Note: Some style options not given explicitly are set to their defaults. This means indent may make changes which the unwary user does not expect!

For example, given the following input, file.c:

      int main(int argc, char *argv[]) {
          if (argc == 1) {
               return 1;
	  }
	  else {
               return 0;
	  }
      }
    

indent file.c produces:

      int
      main (int argc, char *argv[])
      {
        if (argc == 1)
	  {
	    return 1;
	  }
	else
	  {
	    return 0;
	  }
      }
    

And indent -npsl file.c produces:

      int main (int argc, char *argv[])
      {
        if (argc == 1)
	  {
	    return 1;
	  }
	else
	  {
	    return 0;
	  }
      }