Home Download Buy Blog Forum Support

Indentation level different than tab_size

Indentation level different than tab_size

Postby dacap on Fri Dec 23, 2011 3:12 pm

Hi!, does someone know a way to specify an indentation level different than tab_size?

For example, I indent C++ files with 2 spaces, but when I reach 8 spaces I replace them with one tab of 8 chars (tab_size=8). I cannot find an "indentation_size" option or something similar to "tab_size" that represent the indentation level in spaces and instead of tabs.

I think that there are some options missing here (or that I didn't find):
  • indentation_size (integer): number of spaces to use for indent code, which is not the same as "tab_size"
  • compress_spaces_with_tabs_on_indentation (boolean): to specify that spaces should be converted to tabs when you reach a certain level of indentation (e.g. 8 spaces compressed to 1 tab if tab_size=8)
Last edited by dacap on Sat Dec 24, 2011 6:02 pm, edited 1 time in total.
dacap
 
Posts: 8
Joined: Thu Dec 22, 2011 2:44 pm
Location: Santa Fe, Santa Fe, Argentina

Re: Indentation level different than tab_size

Postby bizoo on Fri Dec 23, 2011 3:53 pm

:o
Very original way to indent source code...

What's the purpose ?
bizoo
 
Posts: 886
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Indentation level different than tab_size

Postby dacap on Fri Dec 23, 2011 4:17 pm

bizoo wrote:What's the purpose ?

Backward compatibility with the current way I'm indenting code. Right now I'd prefer to use all spaces (2 spaces for indenting, without tabs). But if you are working in a project that use this kind of (simple) indentation scheme, you should be able to specify: tabs width = 8 and indent level = 2, it doesn't look something so crazy.

PS: Historically tabs were 8 chars long, so having tab_size = 8 and an indent size < 8 is pretty common.
dacap
 
Posts: 8
Joined: Thu Dec 22, 2011 2:44 pm
Location: Santa Fe, Santa Fe, Argentina

Re: Indentation level different than tab_size

Postby svenax on Fri Dec 23, 2011 10:13 pm

bizoo wrote::o
Very original way to indent source code...


Not that original. This is mandated by the GNU coding standard and used in all GNU projects. I believe it is also used in the Linux kernel. But I agree it is a weird way of formatting code.
svenax
 
Posts: 154
Joined: Tue Dec 20, 2011 12:47 pm


Return to General Discussion

Who is online

Users browsing this forum: Google [Bot] and 17 guests