【搬運】【備份】imrc文件

存檔。javascript

 

" =============================================================================
"        << 判斷操做系統是 Windows 仍是 Linux 和判斷是終端仍是 Gvim >>
" =============================================================================

" -----------------------------------------------------------------------------
"  < 判斷操做系統是不是 Windows 仍是 Linux >
" -----------------------------------------------------------------------------
if(has("win32") || has("win64") || has("win95") || has("win16"))
    let g:iswindows = 1
else
    let g:iswindows = 0
endif

" -----------------------------------------------------------------------------
"  < 判斷是終端仍是 Gvim >
" -----------------------------------------------------------------------------
if has("gui_running")
    let g:isGUI = 1
else
    let g:isGUI = 0
endif


" =============================================================================
"                          << 如下爲軟件默認配置 >>
" =============================================================================

" -----------------------------------------------------------------------------
"  < Windows Gvim 默認配置> 作了一點修改
" -----------------------------------------------------------------------------
if (g:iswindows && g:isGUI)
    source $VIMRUNTIME/vimrc_example.vim
    source $VIMRUNTIME/mswin.vim
    behave mswin
    set diffexpr=MyDiff()

    function MyDiff()
        let opt = '-a --binary '
        if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
        if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
        let arg1 = v:fname_in
        if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
        let arg2 = v:fname_new
        if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
        let arg3 = v:fname_out
        if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
        let eq = ''
        if $VIMRUNTIME =~ ' '
            if &sh =~ '\<cmd'
                let cmd = '""' . $VIMRUNTIME . '\diff"'
                let eq = '"'
            else
                let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
            endif
        else
            let cmd = $VIMRUNTIME . '\diff'
        endif
        silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
    endfunction
endif

" -----------------------------------------------------------------------------
"  < Linux Gvim/Vim 默認配置> 作了一點修改
" -----------------------------------------------------------------------------
if !g:iswindows
    set hlsearch        "高亮搜索
    set incsearch       "在輸入要搜索的文字時,實時匹配

    " Uncomment the following to have Vim jump to the last position when
    " reopening a file
    if has("autocmd")
        au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
    endif

    if g:isGUI
        " Source a global configuration file if available
        if filereadable("/etc/vim/gvimrc.local")
            source /etc/vim/gvimrc.local
        endif
    else
        " This line should not be removed as it ensures that various options are
        " properly set to work with the Vim-related packages available in Debian.
        runtime! debian.vim

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

        set mouse=a                    " 在任何模式下啓用鼠標
        set t_Co=256                   " 在終端啓用256色
        set backspace=2                " 設置退格鍵可用

        " Source a global configuration file if available
        if filereadable("/etc/vim/vimrc.local")
            source /etc/vim/vimrc.local
        endif
    endif
endif


" =============================================================================
"                          << 如下爲用戶自定義配置 >>
" =============================================================================

" -----------------------------------------------------------------------------
"  < Vundle 插件管理工具配置 >
" -----------------------------------------------------------------------------
" 用於更方便的管理vim插件,具體用法參考 :h vundle 幫助
" 安裝方法爲在終端輸入以下命令
" git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle

set nocompatible                                      "禁用 Vi 兼容模式
filetype off                                          "禁用文件類型偵測

if !g:iswindows
    set rtp+=~/.vim/bundle/vundle/
    call vundle#rc()
else
    set rtp+=$VIM/vimfiles/bundle/vundle/
    call vundle#rc('$VIM/vimfiles/bundle/')
endif

" 使用Vundle來管理Vundle,這個必需要有。
Bundle 'gmarik/vundle'

" 如下爲要安裝或更新的插件,不一樣倉庫都有(具體書寫規範請參考幫助)
Bundle 'a.vim'
Bundle 'Align'
Bundle 'jiangmiao/auto-pairs'
Bundle 'bufexplorer.zip'
Bundle 'ccvext.vim'
Bundle 'cSyntaxAfter'
Bundle 'Yggdroot/indentLine'
Bundle 'breestealth/Mark-Karkat'
" Bundle 'minibufexpl.vim'
" Bundle 'fholgado/minibufexpl.vim' "這個上的6.4.4版本與 Vundle 插件有一些衝突
Bundle 'Shougo/neocomplcache.vim'
Bundle 'scrooloose/nerdcommenter'
Bundle 'scrooloose/nerdtree'
Bundle 'FromtonRouge/OmniCppComplete'
Bundle 'Lokaltog/vim-powerline'
Bundle 'repeat.vim'
Bundle 'msanders/snipmate.vim'
Bundle 'wesleyche/SrcExpl'
" Bundle 'ervandew/supertab'
Bundle 'std_c.zip'
Bundle 'tpope/vim-surround'
Bundle 'scrooloose/syntastic'
Bundle 'majutsushi/tagbar'
Bundle 'netroby/taglist'
Bundle 'TxtBrowser'
" Bundle 'winmanager'
Bundle 'ZoomWin'

" -----------------------------------------------------------------------------
"  < 編碼配置 >
" -----------------------------------------------------------------------------
" 注:使用utf-8格式後,軟件與程序源碼、文件路徑不能有中文,不然報錯
set encoding=utf-8                                    "設置gvim內部編碼
set fileencoding=utf-8                                "設置當前文件編碼
set fileencodings=ucs-bom,utf-8,gbk,cp936,latin-1     "設置支持打開的文件的編碼

" 文件格式,默認 ffs=dos,unix
set fileformat=unix                                   "設置新文件的<EOL>格式
set fileformats=unix,dos,mac                          "給出文件的<EOL>格式類型

if (g:iswindows && g:isGUI)
    "解決菜單亂碼
    source $VIMRUNTIME/delmenu.vim
    source $VIMRUNTIME/menu.vim

    "解決consle輸出亂碼
    language messages zh_CN.utf-8
endif

" -----------------------------------------------------------------------------
"  < 編寫文件時的配置 >
" -----------------------------------------------------------------------------
filetype on                                           "啓用文件類型偵測
filetype plugin on                                    "針對不一樣的文件類型加載對應的插件
filetype plugin indent on                             "啓用縮進
set smartindent                                       "啓用智能對齊方式
set expandtab                                         "將Tab鍵轉換爲空格
set tabstop=2                                         "設置Tab鍵的寬度
set shiftwidth=2                                      "換行時自動縮進4個空格
set smarttab                                          "指定按一次backspace就刪除shiftwidth寬度的空格
set foldenable                                        "啓用摺疊
set foldmethod=indent                                 "indent 摺疊方式
" set foldmethod=marker                                "marker 摺疊方式

" 用空格鍵來開關摺疊
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>

" 當文件在外部被修改,自動更新該文件
set autoread

" 常規模式下輸入 cS 清除行尾空格
nmap cS :%s/\s\+$//g<cr>:noh<cr>

" 常規模式下輸入 cM 清除行尾 ^M 符號
nmap cM :%s/\r$//g<cr>:noh<cr>

set ignorecase                                        "搜索模式裏忽略大小寫
set smartcase                                         "若是搜索模式包含大寫字符,不使用 'ignorecase' 選項,只有在輸入搜索模式而且打開 'ignorecase' 選項時纔會使用
" set noincsearch                                       "在輸入要搜索的文字時,取消實時匹配

" Ctrl + K 插入模式下光標向上移動
imap <c-k> <Up>

" Ctrl + J 插入模式下光標向下移動
imap <c-j> <Down>

" Ctrl + H 插入模式下光標向左移動
imap <c-h> <Left>

" Ctrl + L 插入模式下光標向右移動
imap <c-l> <Right>

" 每行超過80個的字符用下劃線標示
"au BufWinEnter * let w:m2=matchadd('Underlined', '\%>' . 80 . 'v.\+', -1)

" -----------------------------------------------------------------------------
"  < 界面配置 >
" -----------------------------------------------------------------------------
set number                                            "顯示行號
set laststatus=2                                      "啓用狀態欄信息
set cmdheight=2                                       "設置命令行的高度爲2,默認爲1
set cursorline                                        "突出顯示當前行
" set guifont=YaHei_Consolas_Hybrid:h10                 "設置字體:字號(字體名稱空格用下劃線代替)
set nowrap                                            "設置不自動換行
set shortmess=atI                                     "去掉歡迎界面
au GUIEnter * simalt ~x                              "窗口啓動時自動最大化
" winpos 100 10                                         "指定窗口出現的位置,座標原點在屏幕左上角
" set lines=38 columns=120                              "指定窗口大小,lines爲高度,columns爲寬度

" 設置代碼配色方案
if g:isGUI
    colorscheme Tomorrow-Night-Eighties               "Gvim配色方案
else
    colorscheme Tomorrow-Night-Eighties               "終端配色方案
endif

" 個性化狀欄(這裏提供兩種方式,要使用其中一種去掉註釋便可,不使用反之)
" let &statusline=' %t %{&mod?(&ro?"*":"+"):(&ro?"=":" ")} %1*|%* %{&ft==""?"any":&ft} %1*|%* %{&ff} %1*|%* %{(&fenc=="")?&enc:&fenc}%{(&bomb?",BOM":"")} %1*|%* %=%1*|%* 0x%B %1*|%* (%l,%c%V) %1*|%* %L %1*|%* %P'
" set statusline=%t\ %1*%m%*\ %1*%r%*\ %2*%h%*%w%=%l%3*/%L(%p%%)%*,%c%V]\ [%b:0x%B]\ [%{&ft==''?'TEXT':toupper(&ft)},%{toupper(&ff)},%{toupper(&fenc!=''?&fenc:&enc)}%{&bomb?',BOM':''}%{&eol?'':',NOEOL'}]

" 顯示/隱藏菜單欄、工具欄、滾動條,可用 Ctrl + F11 切換
if g:isGUI
    set guioptions-=m
    set guioptions-=T
    set guioptions-=r
    set guioptions-=L
    map <silent> <c-F11> :if &guioptions =~# 'm' <Bar>
        \set guioptions-=m <Bar>
        \set guioptions-=T <Bar>
        \set guioptions-=r <Bar>
        \set guioptions-=L <Bar>
    \else <Bar>
        \set guioptions+=m <Bar>
        \set guioptions+=T <Bar>
        \set guioptions+=r <Bar>
        \set guioptions+=L <Bar>
    \endif<CR>
endif

" -----------------------------------------------------------------------------
"  < 編譯、鏈接、運行配置 >
" -----------------------------------------------------------------------------
" F9 一鍵保存、編譯、鏈接存並運行
map <F9> :call Run()<CR>
imap <F9> <ESC>:call Run()<CR>

" Ctrl + F9 一鍵保存並編譯
map <c-F9> :call Compile()<CR>
imap <c-F9> <ESC>:call Compile()<CR>

" Ctrl + F10 一鍵保存並鏈接
map <c-F10> :call Link()<CR>
imap <c-F10> <ESC>:call Link()<CR>

let s:LastShellReturn_C = 0
let s:LastShellReturn_L = 0
let s:ShowWarning = 1
let s:Obj_Extension = '.o'
let s:Exe_Extension = '.exe'
let s:Sou_Error = 0

let s:windows_CFlags = 'gcc\ -fexec-charset=gbk\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'
let s:linux_CFlags = 'gcc\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'

let s:windows_CPPFlags = 'g++\ -fexec-charset=gbk\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'
let s:linux_CPPFlags = 'g++\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o'

func! Compile()
    exe ":ccl"
    exe ":update"
    if expand("%:e") == "c" || expand("%:e") == "cpp" || expand("%:e") == "cxx"
        let s:Sou_Error = 0
        let s:LastShellReturn_C = 0
        let Sou = expand("%:p")
        let Obj = expand("%:p:r").s:Obj_Extension
        let Obj_Name = expand("%:p:t:r").s:Obj_Extension
        let v:statusmsg = ''
        if !filereadable(Obj) || (filereadable(Obj) && (getftime(Obj) < getftime(Sou)))
            redraw!
            if expand("%:e") == "c"
                if g:iswindows
                    exe ":setlocal makeprg=".s:windows_CFlags
                else
                    exe ":setlocal makeprg=".s:linux_CFlags
                endif
                echohl WarningMsg | echo " compiling..."
                silent make
            elseif expand("%:e") == "cpp" || expand("%:e") == "cxx"
                if g:iswindows
                    exe ":setlocal makeprg=".s:windows_CPPFlags
                else
                    exe ":setlocal makeprg=".s:linux_CPPFlags
                endif
                echohl WarningMsg | echo " compiling..."
                silent make
            endif
            redraw!
            if v:shell_error != 0
                let s:LastShellReturn_C = v:shell_error
            endif
            if g:iswindows
                if s:LastShellReturn_C != 0
                    exe ":bo cope"
                    echohl WarningMsg | echo " compilation failed"
                else
                    if s:ShowWarning
                        exe ":bo cw"
                    endif
                    echohl WarningMsg | echo " compilation successful"
                endif
            else
                if empty(v:statusmsg)
                    echohl WarningMsg | echo " compilation successful"
                else
                    exe ":bo cope"
                endif
            endif
        else
            echohl WarningMsg | echo ""Obj_Name"is up to date"
        endif
    else
        let s:Sou_Error = 1
        echohl WarningMsg | echo " please choose the correct source file"
    endif
    exe ":setlocal makeprg=make"
endfunc

func! Link()
    call Compile()
    if s:Sou_Error || s:LastShellReturn_C != 0
        return
    endif
    let s:LastShellReturn_L = 0
    let Sou = expand("%:p")
    let Obj = expand("%:p:r").s:Obj_Extension
    if g:iswindows
        let Exe = expand("%:p:r").s:Exe_Extension
        let Exe_Name = expand("%:p:t:r").s:Exe_Extension
    else
        let Exe = expand("%:p:r")
        let Exe_Name = expand("%:p:t:r")
    endif
    let v:statusmsg = ''
	if filereadable(Obj) && (getftime(Obj) >= getftime(Sou))
        redraw!
        if !executable(Exe) || (executable(Exe) && getftime(Exe) < getftime(Obj))
            if expand("%:e") == "c"
                setlocal makeprg=gcc\ -o\ %<\ %<.o
                echohl WarningMsg | echo " linking..."
                silent make
            elseif expand("%:e") == "cpp" || expand("%:e") == "cxx"
                setlocal makeprg=g++\ -o\ %<\ %<.o
                echohl WarningMsg | echo " linking..."
                silent make
            endif
            redraw!
            if v:shell_error != 0
                let s:LastShellReturn_L = v:shell_error
            endif
            if g:iswindows
                if s:LastShellReturn_L != 0
                    exe ":bo cope"
                    echohl WarningMsg | echo " linking failed"
                else
                    if s:ShowWarning
                        exe ":bo cw"
                    endif
                    echohl WarningMsg | echo " linking successful"
                endif
            else
                if empty(v:statusmsg)
                    echohl WarningMsg | echo " linking successful"
                else
                    exe ":bo cope"
                endif
            endif
        else
            echohl WarningMsg | echo ""Exe_Name"is up to date"
        endif
    endif
    setlocal makeprg=make
endfunc

func! Run()
    let s:ShowWarning = 0
    call Link()
    let s:ShowWarning = 1
    if s:Sou_Error || s:LastShellReturn_C != 0 || s:LastShellReturn_L != 0
        return
    endif
    let Sou = expand("%:p")
    let Obj = expand("%:p:r").s:Obj_Extension
    if g:iswindows
        let Exe = expand("%:p:r").s:Exe_Extension
    else
        let Exe = expand("%:p:r")
    endif
    if executable(Exe) && getftime(Exe) >= getftime(Obj) && getftime(Obj) >= getftime(Sou)
        redraw!
        echohl WarningMsg | echo " running..."
        if g:iswindows
            exe ":!%<.exe"
        else
            if g:isGUI
                exe ":!gnome-terminal -e ./%<"
            else
                exe ":!./%<"
            endif
        endif
        redraw!
        echohl WarningMsg | echo " running finish"
    endif
endfunc

" -----------------------------------------------------------------------------
"  < 其它配置 >
" -----------------------------------------------------------------------------
set writebackup                             "保存文件前創建備份,保存成功後刪除該備份
set nobackup                                "設置無備份文件
" set noswapfile                              "設置無臨時文件
set vb t_vb=                                "關閉提示音


" =============================================================================
"                          << 如下爲經常使用插件配置 >>
" =============================================================================

" -----------------------------------------------------------------------------
"  < a.vim 插件配置 >
" -----------------------------------------------------------------------------
" 用於切換C/C++頭文件
" :A     ---切換頭文件並獨佔整個窗口
" :AV    ---切換頭文件並垂直分割窗口
" :AS    ---切換頭文件並水平分割窗口

" -----------------------------------------------------------------------------
"  < Align 插件配置 >
" -----------------------------------------------------------------------------
" 一個對齊的插件,用來——排版與對齊代碼,功能強大,不過用到的機會很少

" -----------------------------------------------------------------------------
"  < auto-pairs 插件配置 >
" -----------------------------------------------------------------------------
" 用於括號與引號自動補全,不過會與函數原型提示插件echofunc衝突
" 因此我就沒有加入echofunc插件

" -----------------------------------------------------------------------------
"  < BufExplorer 插件配置 >
" -----------------------------------------------------------------------------
" 快速輕鬆的在緩存中切換(至關於另外一種多個文件間的切換方式)
" <Leader>be 在當前窗口顯示緩存列表並打開選定文件
" <Leader>bs 水平分割窗口顯示緩存列表,並在緩存列表窗口中打開選定文件
" <Leader>bv 垂直分割窗口顯示緩存列表,並在緩存列表窗口中打開選定文件

" -----------------------------------------------------------------------------
"  < ccvext.vim 插件配置 >
" -----------------------------------------------------------------------------
" 用於對指定文件自動生成tags與cscope文件並鏈接
" 若是是Windows系統, 則生成的文件在源文件所在盤符根目錄的.symbs目錄下(如: X:\.symbs\)
" 若是是Linux系統, 則生成的文件在~/.symbs/目錄下
" 具體用法可參考www.vim.org中此插件的說明
" <Leader>sy 自動生成tags與cscope文件並鏈接
" <Leader>sc 鏈接已存在的tags與cscope文件

" -----------------------------------------------------------------------------
"  < cSyntaxAfter 插件配置 >
" -----------------------------------------------------------------------------
" 高亮括號與運算符等
au! BufRead,BufNewFile,BufEnter *.{c,cpp,h,javascript} call CSyntaxAfter()

" -----------------------------------------------------------------------------
"  < indentLine 插件配置 >
" -----------------------------------------------------------------------------
" 用於顯示對齊線,與 indent_guides 在顯示方式上不一樣,根據本身喜愛選擇了
" 在終端上會有屏幕刷新的問題,這個問題能解決有更好了
" 開啓/關閉對齊線
nmap <leader>il :IndentLinesToggle<CR>

" 設置Gvim的對齊線樣式
if g:isGUI
    let g:indentLine_char = "┊"
    let g:indentLine_first_char = "┊"
endif

" 設置終端對齊線顏色
" let g:indentLine_color_term = 239
"
" 設置 GUI 對齊線顏色
" let g:indentLine_color_gui = '#A4E57E'

" -----------------------------------------------------------------------------
"  < Mark--Karkat(也就是 Mark) 插件配置 >
" -----------------------------------------------------------------------------
" 給不一樣的單詞高亮,代表不一樣的變量時頗有用,詳細幫助見 :h mark.txt

" " -----------------------------------------------------------------------------
" "  < MiniBufExplorer 插件配置 >
" " -----------------------------------------------------------------------------
" " 快速瀏覽和操做Buffer
" " 主要用於同時打開多個文件並相與切換

" " let g:miniBufExplMapWindowNavArrows = 1     "用Ctrl加方向鍵切換到上下左右的窗口中去
" let g:miniBufExplMapWindowNavVim = 1        "用<C-k,j,h,l>切換到上下左右的窗口中去
" let g:miniBufExplMapCTabSwitchBufs = 1      "功能加強(不過好像只有在Windows中才有用)
" "                                            <C-Tab> 向前循環切換到每一個buffer上,並在但前窗口打開
" "                                            <C-S-Tab> 向後循環切換到每一個buffer上,並在當前窗口打開

" 在不使用 MiniBufExplorer 插件時也可用<C-k,j,h,l>切換到上下左右的窗口中去
noremap <c-k> <c-w>k
noremap <c-j> <c-w>j
noremap <c-h> <c-w>h
noremap <c-l> <c-w>l

" -----------------------------------------------------------------------------
"  < neocomplcache 插件配置 >
" -----------------------------------------------------------------------------
" 關鍵字補全、文件路徑補全、tag補全等等,各類,很是好用,速度超快。
let g:neocomplcache_enable_at_startup = 1     "vim 啓動時啓用插件
" let g:neocomplcache_disable_auto_complete = 1 "不自動彈出補全列表
" 在彈出補全列表後用 <c-p> 或 <c-n> 進行上下選擇效果比較好

" -----------------------------------------------------------------------------
"  < nerdcommenter 插件配置 >
" -----------------------------------------------------------------------------
" 我主要用於C/C++代碼註釋(其它的也行),這個插件我作了小點修改,也就是在註釋符
" 與註釋內容間加一個空格
" 如下爲插件默認快捷鍵,其中的說明是以C/C++爲例的
" <Leader>ci 以每行一個 /* */ 註釋選中行(選中區域所在行),再輸入則取消註釋
" <Leader>cm 以一個 /* */ 註釋選中行(選中區域所在行),再輸入則稱重複註釋
" <Leader>cc 以每行一個 /* */ 註釋選中行或區域,再輸入則稱重複註釋
" <Leader>cu 取消選中區域(行)的註釋,選中區域(行)內至少有一個 /* */
" <Leader>ca 在/*...*/與//這兩種註釋方式中切換(其它語言可能不同了)
" <Leader>cA 行尾註釋
let NERDSpaceDelims = 1                     "在左註釋符以後,右註釋符以前留有空格

" -----------------------------------------------------------------------------
"  < nerdtree 插件配置 >
" -----------------------------------------------------------------------------
" 有目錄村結構的文件瀏覽插件

" 常規模式下輸入 F2 調用插件
nmap <F2> :NERDTreeToggle<CR>

" -----------------------------------------------------------------------------
"  < omnicppcomplete 插件配置 >
" -----------------------------------------------------------------------------
" 用於C/C++代碼補全,這種補全主要針對命名空間、類、結構、共同體等進行補全,詳細
" 說明能夠參考幫助或網絡教程等
" 使用前先執行以下 ctags 命令(本配置中能夠直接使用 ccvext 插件來執行如下命令)
" ctags -R --c++-kinds=+p --fields=+iaS --extra=+q
" 我使用上面的參數生成標籤後,對函數使用跳轉時會出現多個選擇
" 因此我就將--c++-kinds=+p參數給去掉了,若是大俠有什麼其它解決方法但願不要保留呀
set completeopt=menu                        "關閉預覽窗口

" -----------------------------------------------------------------------------
"  < powerline 插件配置 >
" -----------------------------------------------------------------------------
" 狀態欄插件,更好的狀態欄效果

" -----------------------------------------------------------------------------
"  < repeat 插件配置 >
" -----------------------------------------------------------------------------
" 主要用"."命令來重複上次插件使用的命令

" -----------------------------------------------------------------------------
"  < snipMate 插件配置 >
" -----------------------------------------------------------------------------
" 用於各類代碼補全,這種補全是一種對代碼中的詞與代碼塊的縮寫補全,詳細用法能夠參
" 考使用說明或網絡教程等。不過有時候也會與 supertab 插件在補全時產生衝突,若是大
" 俠有什麼其它解決方法但願不要保留呀

" -----------------------------------------------------------------------------
"  < SrcExpl 插件配置 >
" -----------------------------------------------------------------------------
" 加強源代碼瀏覽,其功能就像Windows中的"Source Insight"
" :SrcExpl                                   "打開瀏覽窗口
" :SrcExplClose                              "關閉瀏覽窗口
" :SrcExplToggle                             "打開/閉瀏覽窗口

" " -----------------------------------------------------------------------------
" "  < supertab 插件配置 >
" " -----------------------------------------------------------------------------
" " 我主要用於配合 omnicppcomplete 插件,在按 Tab 鍵時自動補全效果更好更快
" " let g:supertabdefaultcompletiontype = "<c-x><c-u>"

" -----------------------------------------------------------------------------
"  < std_c 插件配置 >
" -----------------------------------------------------------------------------
" 用於加強C語法高亮

" 啓用 // 注視風格
let c_cpp_comments = 0

" -----------------------------------------------------------------------------
"  < surround 插件配置 >
" -----------------------------------------------------------------------------
" 快速給單詞/句子兩邊增長符號(包括html標籤),缺點是不能用"."來重複命令
" 不過 repeat 插件能夠解決這個問題,詳細幫助見 :h surround.txt

" -----------------------------------------------------------------------------
"  < Syntastic 插件配置 >
" -----------------------------------------------------------------------------
" 用於保存文件是查檢語法

" -----------------------------------------------------------------------------
"  < Tagbar 插件配置 >
" -----------------------------------------------------------------------------
" 相對 TagList 能更好的支持面向對象

" 常規模式下輸入 tb 調用插件,若是有打開 TagList 窗口則先將其關閉
nmap tb :TlistClose<cr>:TagbarToggle<cr>

let g:tagbar_width=30                       "設置窗口寬度
" let g:tagbar_left=1                         "在左側窗口中顯示

" -----------------------------------------------------------------------------
"  < TagList 插件配置 >
" -----------------------------------------------------------------------------
" 高效地瀏覽源碼, 其功能就像vc中的workpace
" 那裏面列出了當前文件中的全部宏,全局變量, 函數名等

" 常規模式下輸入 tl 調用插件,若是有打開 Tagbar 窗口則先將其關閉
nmap tl :TagbarClose<cr>:Tlist<cr>

let Tlist_Show_One_File=1                   "只顯示當前文件的tags
" let Tlist_Enable_Fold_Column=0              "使taglist插件不顯示左邊的摺疊行
let Tlist_Exit_OnlyWindow=1                 "若是Taglist窗口是最後一個窗口則退出Vim
let Tlist_File_Fold_Auto_Close=1            "自動摺疊
let Tlist_WinWidth=30                       "設置窗口寬度
let Tlist_Use_Right_Window=1                "在右側窗口中顯示

" -----------------------------------------------------------------------------
"  < txtbrowser 插件配置 >
" -----------------------------------------------------------------------------
" 用於文本文件生成標籤與與語法高亮(調用TagList插件生成標籤,若是能夠)
au BufRead,BufNewFile *.txt setlocal ft=txt

" " -----------------------------------------------------------------------------
" "  < WinManager 插件配置 >
" " -----------------------------------------------------------------------------
" " 管理各個窗口, 或者說整合各個窗口

" " 常規模式下輸入 F3 調用插件
" nmap <F3> :WMToggle<cr>

" " 這裏能夠設置爲多個窗口, 如'FileExplorer|TagList'
" let g:winManagerWindowLayout='FileExplorer'

" let g:persistentBehaviour=0                 "只剩一個窗口時, 退出vim
" let g:winManagerWidth=30                    "設置窗口寬度

" -----------------------------------------------------------------------------
"  < ZoomWin 插件配置 >
" -----------------------------------------------------------------------------
" 用於分割窗口的最大化與還原
" 快捷鍵 <c-w>o 在最大化與還原間切換

" =============================================================================
"                          << 如下爲經常使用工具配置 >>
" =============================================================================

" -----------------------------------------------------------------------------
"  < cscope 工具配置 >
" -----------------------------------------------------------------------------
" 用Cscope本身的話說 - "你能夠把它當作是超過頻的ctags"
if has("cscope")
    "設定可使用 quickfix 窗口來查看 cscope 結果
    set cscopequickfix=s-,c-,d-,i-,t-,e-
    "使支持用 Ctrl+]  和 Ctrl+t 快捷鍵在代碼間跳轉
    set cscopetag
    "若是你想反向搜索順序設置爲1
    set csto=0
    "在當前目錄中添加任何數據庫
    if filereadable("cscope.out")
        cs add cscope.out
    "不然添加數據庫環境中所指出的
    elseif $CSCOPE_DB != ""
        cs add $CSCOPE_DB
    endif
    set cscopeverbose
    "快捷鍵設置
    nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
    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>
    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>
endif

" -----------------------------------------------------------------------------
"  < ctags 工具配置 >
" -----------------------------------------------------------------------------
" 對瀏覽代碼很是的方便,能夠在函數,變量之間跳轉等
set tags=./tags;                            "向上級目錄遞歸查找tags文件(好像只有在Windows下才有用)

" -----------------------------------------------------------------------------
"  < gvimfullscreen 工具配置 > 請確保已安裝了工具
" -----------------------------------------------------------------------------
" 用於 Windows Gvim 全屏窗口,可用 F11 切換
" 全屏後再隱藏菜單欄、工具欄、滾動條效果更好
if (g:iswindows && g:isGUI)
    map <F11> <Esc>:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR>
endif

" -----------------------------------------------------------------------------
"  < vimtweak 工具配置 > 請確保以已裝了工具
" -----------------------------------------------------------------------------
" 這裏只用於窗口透明與置頂
" 常規模式下 Shift + k 減少透明度,Shift + j 增長透明度,<Leader>t 窗口置頂與否切換
if (g:iswindows && g:isGUI)
    let g:Current_Alpha = 255
    let g:Top_Most = 0
    func! Alpha_add()
        let g:Current_Alpha = g:Current_Alpha + 10
        if g:Current_Alpha > 255
            let g:Current_Alpha = 255
        endif
        call libcallnr("vimtweak.dll","SetAlpha",g:Current_Alpha)
    endfunc
    func! Alpha_sub()
        let g:Current_Alpha = g:Current_Alpha - 10
        if g:Current_Alpha < 155
            let g:Current_Alpha = 155
        endif
        call libcallnr("vimtweak.dll","SetAlpha",g:Current_Alpha)
    endfunc
    func! Top_window()
        if  g:Top_Most == 0
            call libcallnr("vimtweak.dll","EnableTopMost",1)
            let g:Top_Most = 1
        else
            call libcallnr("vimtweak.dll","EnableTopMost",0)
            let g:Top_Most = 0
        endif
    endfunc
    "快捷鍵設置
    map <s-k> :call Alpha_add()<cr>
    map <s-j> :call Alpha_sub()<cr>
    map <leader>t :call Top_window()<cr>
endif

" =============================================================================
"                          << 如下爲經常使用自動命令配置 >>
" =============================================================================

" 自動切換目錄爲當前編輯文件所在目錄
au BufRead,BufNewFile,BufEnter * cd %:p:h

" =============================================================================
"                          << 其它 >>
" =============================================================================

" 注:上面配置中的"<Leader>"在本軟件中設置爲"\"鍵(引號裏的反斜槓),如<Leader>t
" 指在常規模式下按"\"鍵加"t"鍵,這裏不是同時按,而是先按"\"鍵後按"t"鍵,間隔在一
" 秒內,而<Leader>cs是先按"\"鍵再按"c"又再按"s"鍵
"
hi Normal  ctermfg=252 ctermbg=none
"
相關文章
相關標籤/搜索