You can see what type of tab is currently in use with the Mx describe-variable RET c-indentation-style (but as indicated in the documentation, do not set this variable directly, but use Mx c-set-style ).
The c-basic-offset variable is what controls tabs in cc-mode , and its default is set-from-style , which means that tabbing will be inherited from the C style you set with Mx set-c-style , which allows you to choose built-in styles from a set (see below), or you can create your own style . You can see how styles are defined using Mx describe-variable RET c-style-alist , and then you can use one of them as a template with Mx c-add-style .
- gnu is a coding style blessed by the Free Software Foundation for C code in GNU programs.
- k & r is the classic Kernighan and Ritchie style for code C.
- bsd - also known as "Allman style" after Eric Alman.
- whitesmith. Popularized with examples that came with Whitesmiths C, an early commercial C compiler.
- strustrup is the classic Stroustrup style for C ++ code.
- ellemtel - popular C ++ coding standards defined by "C ++ Programming Rules and Recommendations", Eric Nyquist and Mats Henrison, Ellemtel ^ 1.
- linux is the C encoding standard for Linux (kernel).
- python is the C coding standard for Python ^ 2 extension modules.
- java . Style for editing Java code. Please note that the default value for the c-default style sets this style when entering java mode.
- awk - AWK code editing style. Note that the default value for the c-default style sets this style when entering awk mode.
- user This is a special style created by you. It consists of the factory defaults for all style variables that are changed using the settings that you perform either through the settings interface, or by writing setqs and c-set-offsets at the top level of your .emacs file (see the Configuration Basics section) . The style system creates this style as part of its initialization and does not change it subsequently.
UPDATE:
Others suggested using the tab key to insert the tab character \t , but not to force the tab character! As one of the creators, StackOverflow says "only the moron will use tabs to format his code . " Now it's a little harsh, but it is worth noting that even the two most giant competitor, the Google and the Microsoft , settle this question (although they recommend a different number of spaces by default).
Google says :
Use only spaces and indents 2 spaces at a time.
Microsoft says :
Tab characters (\ 0x09) should not be used in code. All indentation should be done with 4 spaces.
In addition, emacswiki has a βTabs of Evilβ section.
So go ahead and donβt take care !
source share