Code formatting tool in Linux: Indent
Under Ubuntu: $ sudo apt-Get install indent
Common settings:
Indent-NPRO-Kr-I4-ts4-sob-L80-SS-bl-Bli 0 file name
Parameter description:
-NPRO or -- ignore-profile do not read indent's configuration file. indent. Pro.
-Kr specifies the format of kernighan & Ritchie. It can be changed to-orig or BSD.
-I4 -- indent-level: set the number of cells to 4.
-Ts4: Set the tab Length
-Sob or -- swallow-optional-blank-lines Delete unnecessary blank lines.
-Line feed of L80 Code exceeding 80
-SS or -- space-special-semicolon if the for section contains only one line, add a space before the semicolon.
-NCs or -- no-space-after-casts should not be empty after cast.
-BL {branch display
-Bli 0 parentheses indent to 0
Note:
<1>-set both I4 and ts4
-I4: specifies the number of indentations. If it is an integer multiple of tabs, tab is used for indenting. Otherwise, spaces are used for filling.
-I4-ts4 cannot be indented by four spaces, but by a tab.
When you use Vim to view code,
Only set Ts = 4 in. vimrc
The code is Indented by four spaces.
<2> fileformats = UNIX, DoS
In Vim command mode, enter ": Set FFS" to obtain: fileformats = UNIX, DoS
Therefore, VIM supports both UNIX and DOS formats (different row Terminator)
Enter ": Set FF" to obtain the current file format.
If the format of the file to be converted is dos, there will be more ^ m after indent conversion.
Solution:
: Set FF = Unix
: WQ
$ Indent...
In this way, you can.
Refer:
Http://hi.baidu.com/houhou1999/blog/item/4983d41b680825c5ac6e75cd.html