LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1027|回复: 4

关于用vi编程的问题

[复制链接]
发表于 2005-10-17 21:45:31 | 显示全部楼层 |阅读模式
我用vi写*.c文件,但是换行时不能自动缩进(turboC等环境下都可以自动缩进的),请问可以解决吗?或者用别的什么编辑程序?
谢谢!
发表于 2005-10-17 23:16:03 | 显示全部楼层
换新版本
回复 支持 反对

使用道具 举报

发表于 2005-10-18 00:05:11 | 显示全部楼层
1. Indenting C programs                                 *C-indenting*

The basics for C indenting are explained in section |30.2| of the user manual.

Vim has options for automatically indenting C program files.  These options
affect only the indent and do not perform other formatting.  For comment
formatting, see |format-comments|.

Note that this will not work when the |+smartindent| or |+cindent| features
have been disabled at compile time.

There are in fact four methods available for indentation:
'autoindent'    uses the indent from the previous line.
'smartindent'   is like 'autoindent' but also recognizes some C syntax to
                increase/reduce the indent where appropriate.
'cindent'       Works more cleverly than the other two and is configurable to
                different indenting styles.
'indentexpr'    The most flexible of all: Evaluates an expression to compute
                the indent of a line.  When non-empty this method overrides
                the other ones.  See |indent-expression|.
The rest of this section describes the 'cindent' option.

Note that 'cindent' indenting does not work for every code scenario.  Vim
is not a C compiler: it does not recognize all syntax.

These four options control C program indenting:
'cindent'       Enables Vim to perform C program indenting automatically.
'cinkeys'       Specifies which keys trigger reindenting in insert mode.
'cinoptions'    Sets your preferred indent style.
'cinwords'      Defines keywords that start an extra indent in the next line.

If 'lisp' is not on and 'equalprg' is empty, the "=" operator indents using
Vim's built-in algorithm rather than calling an external program.

See |autocommand| for how to set the 'cindent' option automatically for C code
files and reset it for others.
回复 支持 反对

使用道具 举报

发表于 2005-10-18 00:08:25 | 显示全部楼层
在你的/etc/vimrc里加上
filetype plugin indent on

这一行就可以自动缩进了。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-10-19 20:18:14 | 显示全部楼层
多谢!!!
回复 支持 反对

使用道具 举报

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

本版积分规则

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