"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 nobackup " Don't write backup file if vim is being called by "chpass" au BufWrite /private/etc/pw.* set nowritebackup nobackup "onfiguration 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 syntax on " 語法高亮 set smartindent " 智能對齊 set autoindent " 自動對齊 set confirm " 在處理未保存或只讀文件的時候,彈出確認 set tabstop=4 " Tab鍵的寬度 set softtabstop=4 set shiftwidth=4 " 統一縮進爲4 set number " 顯示行號 set history=50 " 歷史紀錄數 set hlsearch set incsearch " 搜索逐字符高亮 set gdefault " 行內替換 set encoding=utf-8 set fileencodings=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936,utf-16,big5,euc-jp,latin1 " 編碼設置 "colorscheme torte " 設置顏色主題 "set guifont=Menlo:h16:cANSI " 設置字體 set langmenu=zn_CN.UTF-8 set helplang=cn " 語言設置 set cmdheight=2 " 命令行(在狀態行)的高度,默認爲1,這裏是2 set ruler " 在編輯過程當中,在右下角顯示光標位置的狀態行 set laststatus=2 " 老是顯示狀態行 set showcmd " 在狀態行顯示目前所執行的命令,未完成的指令片斷亦會顯示出來 set scrolloff=3 " 光標移動到buffer的頂部和底部時保持3行距離 set showmatch " 高亮顯示對應的括號 set matchtime=5 " 對應括號高亮的時間(單位是十分之一秒) set autowrite " 在切換buffer時自動保存當前文件 set wildmenu " 加強模式中的命令行自動完成操做 set linespace=2 " 字符間插入的像素行數目 set whichwrap=b,s,<,>,[,] " 開啓Normal或Visual模式下Backspace鍵,空格鍵,左方向鍵,右方向鍵,Insert或replace模式下左方向鍵,右方向鍵跳行的功能。 filetype plugin indent on " 分爲三部分命令:file on, file plugin on, file indent on.分別表示自動識別文件類型,用文件類型腳本,使用縮進定義文件。 "==================自定義的鍵映射====================== vnoremap $1 <esc>`>a)<esc>`<i(<esc> vnoremap $2 <esc>`>a]<esc>`<i[<esc> vnoremap $3 <esc>`>a}<esc>`<i{<esc> vnoremap $$ <esc>`>a"<esc>`<i"<esc> vnoremap $q <esc>`>a'<esc>`<i'<esc> vnoremap $e <esc>`>a"<esc>`<i"<esc> " 括號自動生成 map <F7> :if exists("syntax_on") <BAR> \ syntax off <BAR><CR> \ else <BAR> \syntax enable <BAR> \ endif " 單鍵<F7>控制syntax on/off。緣由是有時候顏色太多會妨礙閱讀。 map <F5> :call CompileRunGcc()<CR> func! CompileRunGcc() exec "w" exec "!gcc % -o %<" exec "! ./%<" endfunc " <F5>編譯和運行C程序 map <F6> :call CompileRunGpp<CR> func! CompileRunGpp() exec "w" exec "!g++ % -o %<" exec "! ./<" endfunc " <F6>編譯和運行C++程序 " 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 "cscope設置 if has("cscope") set csprg=/usr/bin/cscope "set cscopequickfix=s-,c-,d-,i-,t-,e- set csto=0 set cst set nocsverb " add any database in current directory if filereadable("cscope.out") cs add cscope.out " else add database pointed to by environment elseif $CSCOPE_DB != "" cs add $CSCOPE_DB endif set csverb endif nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR> "search for this c symbol nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR> nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR> nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR> "search for this string nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR> nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR> nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR> nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>