LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
12
返回列表 发新帖
楼主: haohao_h

vim能不能像vc那样自动排版?

[复制链接]
 楼主| 发表于 2005-11-27 01:08:35 | 显示全部楼层
用了一下astyle,感觉除了--break-blocks选项外,其余的跟cindent差不多。像"="前后加空格,逗号后面加空格这些功能都没有实现。下满是我根据帮助文档写的配置文件。

  1. #Predefined Styling options:
  2. #---------------------------------------
  3. --style=ansi
  4. #ANSI style formatting/indenting.

  5. #--style=kr
  6. #Kernighan&Ritchie style formatting/indenting.

  7. #--style=gnu
  8. #GNU style formatting/indenting.

  9. #--style=java
  10. #Java mode, with standard java style formatting/indenting.

  11. #--style=linux
  12. #Linux mode (i.e. 8 spaces per indent, break definition-block
  13. #                brackets but attach command-block brackets.

  14.                
  15. #Indentation options:
  16. #-------------------------------------------
  17. --mode=c
  18. #                -c   OR   --mode=c
  19. #                Indent a C, C++ or C# source file (default)

  20. #                -j   OR   --mode=java
  21. #                Indent a Java(TM) source file

  22. #                -s   OR   -s#   OR   --indent=spaces=#
  23. #                Indent using # spaces per indent. Not specifying #
  24. #                will result in a default of 4 spacec per indent.

  25. #                -t   OR   -t#   OR   --indent=tab=#
  26. #                Indent using tab characters, assuming that each
  27. #                tab is # spaces long. Not specifying # will result
  28. #                in a default assumption of 4 spaces per tab.

  29. #                -T#   OR   --force-indent=tab=#    Indent using tab characters, assuming that each
  30. #                tab is # spaces long. Force tabs to be used in areas
  31. #                Astyle would prefer to use spaces.

  32. #-C   OR   --indent-classes
  33. #Indent 'class' blocks, so that the inner 'public:',
  34. #           'protected:' and 'private: headers are indented in
  35. #           relation to the class block.

  36. #--indent-switches
  37. #           -S   OR   --indent-switches
  38. #           Indent 'switch' blocks, so that the inner 'case XXX:'
  39. #           headers are indented in relation to the switch block.

  40. #--indent-cases
  41. #           -K   OR   --indent-cases
  42. #           Indent 'case XXX:' lines, so that they are flush with
  43. #           their bodies..

  44. #           -N   OR   --indent-namespaces
  45. #           Indent the contents of namespace blocks.

  46. #--indent-brackets
  47. #           -B   OR   --indent-brackets
  48. #           Add extra indentation to '{' and '}' block brackets.

  49. #           -G   OR   --indent-blocks
  50. #           Add extra indentation entire blocks (including brackets).

  51. #           -L   OR   --indent-labels
  52. #           Indent labels so that they appear one indent less than
  53. #           the current indentation level, rather than being
  54. #           flushed completely to the left (which is the default).

  55. #           -m#  OR  --min-conditional-indent=#
  56. #           Indent a minimal # spaces in a continuous conditional
  57. #           belonging to a conditional header.

  58. #           -M#  OR  --max-instatement-indent=#
  59. #           Indent a maximal # spaces in a continuous statement,
  60. #           relatively to the previous line.

  61. #           -E  OR  --fill-empty-lines
  62. #           Fill empty lines with the white space of their
  63. #           previous lines.

  64. --indent-preprocessor
  65. #           --indent-preprocessor
  66. #           Indent multi-line #define statements

  67. # Formatting options:
  68. # -------------------------------------------------
  69. #           -b  OR  --brackets=break
  70. #           Break brackets from pre-block code (i.e. ANSI C/C++ style).

  71. #           -a  OR  --brackets=attach
  72. #           Attach brackets to pre-block code (i.e. Java/K&R style).

  73. #           -l  OR  --brackets=linux
  74. #           Break definition-block brackets and attach command-block
  75. #           brackets.

  76. #           --brackets=break-closing-headers
  77. #           Break brackets before closing headers (e.g. 'else', 'catch', ..).
  78. #           Should be appended to --brackets=attach or --brackets=linux.

  79. #           -o   OR  --one-line=keep-statements
  80. #           Don't break lines containing multiple statements into
  81. #           multiple single-statement lines.

  82. #           -O   OR  --one-line=keep-blocks
  83. #           Don't break blocks residing completely on one line
  84. #
  85. #           -p   OR  --pad=oper
  86. #           Insert space paddings around operators only.

  87. #           --pad=paren
  88. #           Insert space paddings around parenthesies only.
  89. #
  90. #           -P   OR  --pad=all
  91. #           Insert space paddings around operators AND parenthesies.

  92. #           --convert-tabs
  93. #           Convert tabs to spaces.

  94. --break-blocks
  95. #           --break-blocks
  96. #           Insert empty lines around unrelated blocks, labels, classes, ...

  97. #           --break-blocks=all
  98. #           Like --break-blocks, except also insert empty lines
  99. #           around closing headers (e.g. 'else', 'catch', ...).

  100. #--break-elseifs
  101. #           --break-elseifs
  102. #           Break 'else if()' statements into two different lines.

  103. #Other options:
  104. #-----------------------------------------------------------
  105. #           --suffix=####
  106. #           Append the suffix #### instead of '.orig' to original filename.

  107. #           -X   OR  --errors-to-standard-output
  108. #           Print errors and help information to standard-output rather than
  109. #           to standard-error.

  110. #           -v   OR   --version
  111. #           Print version number

  112. #           -h   OR   -?   OR   --help
  113. #           Print this help message
  114. #Default options file:
  115. #-----------------------------------------------------------
  116. #Artistic Style looks for a default options file in the
  117. #following order:
  118. #1. The contents of the ARTISTIC_STYLE_OPTIONS environment
  119. #variable if it exists.
  120. #2. The file called .astylerc in the directory pointed to by the
  121. #HOME environment variable ( i.e. $HOME/.astylerc ).
  122. #3. The file called .astylerc in the directory pointed to by the
  123. #HOMEPATH environment variable ( i.e. %HOMEPATH%\.astylerc ).
  124. #If a default options file is found, the options in this file
  125. #will be parsed BEFORE the command-line options.
  126. #Options within the default option file may be written without
  127. #the preliminary '-' or '--'.

复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表