天天看點

我的_vimrc

以前用的_my_vimrc

"設定預設主題色20110708

colorscheme murphy

set nobackup

"設定vim IDE 20110902

if(has("win32") || has("win95") || has("win64") || has("win16")) "判定目前作業系統類型

    let g:iswindows=1

else

    let g:iswindows=0

endif

set nocompatible "不要vim模仿vi模式,建議設定,否則會有很多不相容的問題

syntax on"打開高亮

if has("autocmd")

    filetype plugin indent on "根據檔案進行縮進

    augroup vimrcEx

        au!

        autocmd FileType text setlocal textwidth=78

        autocmd BufReadPost *

                    \ if line("'\"") > 1 && line("'\"") <= line("$") |

                    \ exe "normal! g`\"" |

                    \ endif

    augroup END

else

    "智能縮進,相應的有cindent,官方說autoindent可以支援各種檔案的縮進,但是效果會比隻支援C/C++的cindent效果會差一點,但筆者并沒有看出來

    set autoindent " always set autoindenting on 

endif " has("autocmd")

set tabstop=4 "讓一個tab等于4個空格

set vb t_vb=

set nowrap "不自動換行

set hlsearch "高亮顯示結果

set incsearch "在輸入要搜尋的文字時,vim會實時比對

set backspace=indent,eol,start whichwrap+=<,>,[,] "允許倒退鍵的使用

if(g:iswindows==1) "允許滑鼠的使用

    "防止linux終端下無法拷貝

    if has('mouse')

        set mouse=a

    endif

    au GUIEnter * simalt ~x

endif

"字型的設定

set guifont=Bitstream_Vera_Sans_Mono:h10:cANSI "記住空格用下劃線代替哦

set gfw=幼圓:h11:cGB2312 

set fileencodings=utf-8,gb2312,gbk,gb18030

"cpp Program 

map <F12> :call Do_CsTag()<CR>

nmap <[email protected]>s :cs find s <C-R>=expand("<cword>")<CR><CR>:copen<CR>

nmap <[email protected]>g :cs find g <C-R>=expand("<cword>")<CR><CR>

nmap <[email protected]>c :cs find c <C-R>=expand("<cword>")<CR><CR>:copen<CR>

nmap <[email protected]>t :cs find t <C-R>=expand("<cword>")<CR><CR>:copen<CR>

nmap <[email protected]>e :cs find e <C-R>=expand("<cword>")<CR><CR>:copen<CR>

nmap <[email protected]>f :cs find f <C-R>=expand("<cfile>")<CR><CR>:copen<CR>

nmap <[email protected]>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>:copen<CR>

nmap <[email protected]>d :cs find d <C-R>=expand("<cword>")<CR><CR>:copen<CR>

function Do_CsTag()

    let dir = getcwd()

    if filereadable("tags")

        if(g:iswindows==1)

            let tagsdeleted=delete(dir."\\"."tags")

        else

            let tagsdeleted=delete("./"."tags")

        endif

        if(tagsdeleted!=0)

            echohl WarningMsg | echo "Fail to do tags! I cannot delete the tags" | echohl None

            return

        endif

    endif

    if has("cscope")

        silent! execute "cs kill -1"

    endif

    if filereadable("cscope.files")

        if(g:iswindows==1)

            let csfilesdeleted=delete(dir."\\"."cscope.files")

        else

            let csfilesdeleted=delete("./"."cscope.files")

        endif

        if(csfilesdeleted!=0)

            echohl WarningMsg | echo "Fail to do cscope! I cannot delete the cscope.files" | echohl None

            return

        endif

    endif

    if filereadable("cscope.out")

        if(g:iswindows==1)

            let csoutdeleted=delete(dir."\\"."cscope.out")

        else

            let csoutdeleted=delete("./"."cscope.out")

        endif

        if(csoutdeleted!=0)

            echohl WarningMsg | echo "Fail to do cscope! I cannot delete the cscope.out" | echohl None

            return

        endif

    endif

    if(executable('ctags'))

        "silent! execute "!ctags -R --c-types=+p --fields=+S *"

        silent! execute "!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ."

    endif

    if(executable('cscope') && has("cscope") )

        if(g:iswindows!=1)

            silent! execute "!find . -name '*.h' -o -name '*.c' -o -name '*.cpp' -o -name '*.java' -o -name '*.cs' > cscope.files"

        else

            silent! execute "!dir /s/b *.c,*.cpp,*.h,*.java,*.cs >> cscope.files"

        endif

        silent! execute "!cscope -b"

        execute "normal :"

        if filereadable("cscope.out")

            execute "cs add cscope.out"

        endif

    endif

endfunction 

"進行Tlist的設定

"TlistUpdate可以更新tags

map <F4> :silent! NERDTree<CR> "呼出NerdTree

map <F3> :silent! Tlist<CR> "按下F3就可以呼出了

let Tlist_Ctags_Cmd='ctags' "因為我們放在環境變量裡,是以可以直接執行

let Tlist_Use_Right_Window=1 "讓視窗顯示在右邊,0的話就是顯示在左邊

let Tlist_Show_One_File=0 "讓taglist可以同時展示多個檔案的函數清單,如果想隻有1個,設定為1

let Tlist_File_Fold_Auto_Close=1 "非目前檔案,函數清單折疊隐藏

let Tlist_Exit_OnlyWindow=1 "當taglist是最後一個分割視窗時,自動推出vim

"是否一直處理tags.1:處理;0:不處理

let Tlist_Process_File_Always=0 "不是一直實時更新tags,因為沒有必要

let Tlist_Inc_Winwidth=0 

"設定mapleader鍵

let mapleader = ','

filetype plugin on