现在的位置: 首页 > 综合 > 正文

vim配置。(语法高亮+tab+自动缩进)

2013年01月02日 ⁄ 综合 ⁄ 共 1014字 ⁄ 字号 评论关闭

这是本人第一次配置VIM,都是一点简单的。

os:ubuntu   Version:11.10,VIM version : 7.3.154

账户:root,配置文件所在位置: /etc/vim/vimrc

os:CentOS  Version:6.4 

账户:root  配置文件所在位置: /etc/vimrc

在vim配置文件中 ,双引号代表的是注释

先介绍下vim本来就有有可能要配置的:

" Uncomment the next line to make Vim more Vi-compatible

" NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.

"set compatible     "将下面一行注释去掉以后,功能去掉的有关vi一致性模式,避免以前版本的一些bug和局限 ,backspace 将与left键的功能一样的。

" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
  syntax on
endif       

"上面的几句应该是开启语法高亮显示的。但是我没有找到has(“syntax”)相关的信息的。如果有以上语句,而没有高亮,可以自己添加一行写上“syntax on”

需要添加的

set number         "display list number 显示行号
set tabstop=4        "将tab键设置成四个空格
set shiftwidth=4       "表示在使用smartindent时候。按回车产生的缩进是4个空格,而是不是8个标准的tab,详细见注释。
set autoindent          "采用当前的格式应用到下一行。主要是前面有多少空格和tab键
set smartindent        "本行个人该觉用处不大。就是在嵌套语句的时候,下一行自动添加一个tab距离。
                                    "主要用在函数,if、while、for等语句的第一行。但是结束时候有时候无法消除一 个tab的,比如函数结尾、for,while结尾后。

抱歉!评论已关闭.