" Configuration file for vim
set modelines=0 " CVE-2007-2438
" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible " Use Vim defaults instead of 100% vi compatibility
set backspace=2 " more powerful backspacing
" Don't write backup file if vim is being called by "crontab -e"
au BufWrite /private/tmp/crontab.* set nowritebackup
" Don't write backup file if vim is being called by "chpass"
au BufWrite /private/etc/pw.* set nowritebackup
" 自动语法高亮
syntax enable
set background=dark
colorscheme Guardian
" 突出显示当前行
" set cursorline
" 显示行号
set number
" 用空格代替制表符
set expandtab
" 设定 tab 长度为 4
set tabstop=4
" 统一缩进为4
set softtabstop=4
" 自动缩进的宽度
set shiftwidth=4
" 智能自动缩进(这个东西实际用处不大,因为只是针对简单文本的)
" set autoindent
set smartindent
" 让filetype-plugin根据文件类型自动缩进(这个必须要,它会根据文件类型自动配置缩进,插件在安装vim的时候已经装好了)
filetype plugin indent on
" 在行和段开始处使用制表符
set smarttab
"搜索忽略大小写
set ignorecase
"搜索逐字符高亮
set hlsearch
set incsearch
"代码补全
" 关掉智能补全时的预览窗口
" set completeopt=longest,menu
" vim7.3中已经集成了omnicppcomplete了
set omnifunc=omni
" omnicppcomplete配置 关闭兼容模式
set nocp
" 打开文件类型检测,加了这句才可以用智能补全
filetype plugin on
set ofu=syntaxcomplete#Complete
"共享剪贴板
"set clipboard+=unnamed
" 实现 (、[、{、"、' 输入后自动补全右边部分,光标也会位于中间位置
inoremap ( ()i
inoremap [ []i
inoremap { {}i
inoremap < <>i
inoremap " ""i
inoremap ' ''i
" 高亮显示匹配的括号
set showmatch
" 匹配括号高亮的时间(单位是十分之一秒)
set matchtime=1
"保存.vimrc文件后会自动调用新的.vimrc
autocmd! bufwritepost _vimrc source $VIM/_vimrc
" 代码折叠
set foldmethod=marker
" 状态栏显示目前所执行的指令
set showcmd
" 行号和标尺
set number
set ruler
set rulerformat=%15(%c%V %p%%%)
" 设置less文件的高亮
au BufNewFile,BufRead *.less set filetype=less
" 始终显示状态行
set ls=2
"命令行补全以增强模式运行
set wildmenu
原创内容,欢迎转载 😊