breakonthrough
breakonthrough

Reputation: 53

Use the GNU indent command to apply K&R style with only tabs

I've been trying to use GNU indent to indent some very simple C files, and I wish to use the K&R indentation style but without any use of spaces, purely tabs.

I've tried indent -kr --use-tabs, and just indent -kr but they both just use the default K&R with spaces or mix indentation with spaces and tabs.

Is there a way to use K&R with GNU indent while strictly using tabs only? If not, is there a better utility for indentation in this style?

Upvotes: 3

Views: 1836

Answers (1)

Clifford
Clifford

Reputation: 93554

The default assumed width of a tab in GNU indent is 8 (because historically that is what line-printers, teletypes and dumb terminals use). If your indent width is not then a multiple of 8, the tool will mix tabs and spaces to meet your indent width specification.

You need to set the tab width to match your indent with the --tab-size / -ts option, as described in the documentation.

Upvotes: 8

Related Questions