vim配置文件
我的vim配置文件,若有改动会随时更新:
百度网盘地址:http://pan.baidu.com/s/1zLmns
1 "设置编码 2 set encoding=utf-8 3 set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 4 set fileencodings=utf-8,ucs-bom,chinese 5 6 "语言设置 7 set langmenu=zh_CN.UTF-8 8 9 "设置语法高亮 10 syntax enable 11 syntax on 12 13 " 显示行号 14 set nu 15 16 " 自动补全 17 18 :inoremap ( ()<ESC>i 19 :inoremap ) <c-r>=ClosePair(')')<CR> 20 :inoremap { {<CR>}<ESC>O 21 :inoremap } <c-r>=ClosePair('}')<CR> 22 :inoremap [ []<ESC>i 23 :inoremap ] <c-r>=ClosePair(']')<CR> 24 :inoremap " ""<ESC>i 25 :inoremap ' ''<ESC>i 26 function! ClosePair(char) 27 if getline('.')[col('.') - 1] == a:char 28 return "\<Right>" 29 else 30 return a:char 31 endif 32 endfunction 33 filetype plugin indent on 34 "打开文件类型检测, 加了这句才可以用智能补全 35 set completeopt=longest,menu 36 37 38 " 显示标尺 39 set ruler 40 41 " 状态行 42 set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} 43 44 " 启动显示状态行(1),总是显示状态行(2) 45 set laststatus=2 46 47 "搜索逐字符高亮 48 set hlsearch 49 set incsearch 50 51 " 用浅色高亮当前行 52 autocmd InsertLeave * se nocul 53 autocmd InsertEnter * se cul 54 55 56 "可以在buffer的任何地方使用鼠标 57 set mouse=n 58 "set selection=exclusive 59 "set selectmode=mouse,key 60 61 "高亮显示匹配的括号 62 set showmatch 63 64 "去掉vi一致性 65 set nocompatible 66 67 "设置缩进 68 set tabstop=4 69 set softtabstop=4 70 set shiftwidth=4 71 set autoindent 72 set cindent 73 if &term=="xterm" 74 set t_Co=8 75 set t_Sb=^[[4%dm 76 set t_Sf=^[[3%dm 77 endif 78 79 nmap <C-@>s :cs find s <C-R>=expand("<cword>")<CR><CR>:copen<CR> 80 nmap <C-@>g :cs find g <C-R>=expand("<cword>")<CR><CR> 81 nmap <C-@>c :cs find c <C-R>=expand("<cword>")<CR><CR>:copen<CR> 82 nmap <C-@>t :cs find t <C-R>=expand("<cword>")<CR><CR>:copen<CR> 83 nmap <C-@>e :cs find e <C-R>=expand("<cword>")<CR><CR>:copen<CR> 84 nmap <C-@>f :cs find f <C-R>=expand("<cfile>")<CR><CR>:copen<CR> 85 nmap <C-@>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>:copen<CR> 86 nmap <C-@>d :cs find d <C-R>=expand("<cword>")<CR><CR>:copen<CR> 87 88 "打开文件类型自动检测功能 89 filetype on 90 91 "设置taglist 92 let Tlist_Show_One_File=0 "显示多个文件的tags 93 let Tlist_File_Fold_Auto_Close=1 "非当前文件,函数列表折叠隐藏 94 let Tlist_Exit_OnlyWindow=1 "在taglist是最后一个窗口时退出vim 95 let Tlist_Use_SingleClick=1 "单击时跳转 96 let Tlist_GainFocus_On_ToggleOpen=1 "打开taglist时获得输入焦点 97 let Tlist_Process_File_Always=1 "不管taglist窗口是否打开,始终解析文件中的tag 98 99 "设置WinManager插件 100 let g:winManagerWindowLayout='FileExplorer|TagList' 101 nmap wm :WMToggle<cr> 102 map <silent> <F9> :WMToggle<cr> "将F9绑定至WinManager,即打开WimManager 103 104 "设置CSCOPE 105 set cscopequickfix=s-,c-,d-,i-,t-,e- "设定是否使用quickfix窗口显示cscope结果 106 107 :set paste 108 109 if has("cscope") 110 set csprg=/usr/bin/cscope 111 set csto=0 112 set cst 113 set csverb 114 set cspc=3 115 "add any database in current dir 116 if filereadable("cscope.out") 117 cs add cscope.out 118 "else search cscope.out elsewhere 119 else 120 let cscope_file=findfile("cscope.out", ".;") 121 let cscope_pre=matchstr(cscope_file, ".*/") 122 if !empty(cscope_file) && filereadable(cscope_file) 123 exe "cs add" cscope_file cscope_pre 124 endif 125 endif 126 endif 127 128 nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR> 129 nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR> 130 nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR> 131 nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR> 132 nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR> 133 nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR> 134 nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR> 135 nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR> 136 137 "设置Grep插件 138 nnoremap <silent> <F3> :Grep<CR> 139 140 "设置一键编译 141 map <F6> :make<CR> 142 143 "设置自动补全 144 filetype plugin indent on "打开文件类型检测 145 set completeopt=longest,menu "关掉智能补全时的预览窗口 146 147 "设置默认shell 148 set shell=bash 149 150 "设置VIM记录的历史数 151 set history=400 152 153 "设置当文件被外部改变的时侯自动读入文件 154 if exists("&autoread") 155 set autoread 156 endif 157 158 "设置ambiwidth 159 set ambiwidth=double 160 161 "设置文件类型 162 set ffs=unix,dos,mac 163 164 "设置增量搜索模式 165 set incsearch 166 167 "设置静音模式 168 set noerrorbells 169 set novisualbell 170 set t_vb= 171 172 "不要备份文件 173 set nobackup 174 set nowb