天天看點

my_vimrc

" add by badboy 2012-1-2

if has("win32") || has("win95") || has("win64") || has("win16")

    let g:iswindows=1

else

    let g:iswindows=0

endif

if has("autocmd")

    filetype plugin indent on

endif

set nu

"set cin

set wildmenu

"光标所在行高亮

set cursorline

"set cursorcolumn

set autoindent

syntax enable

set nocompatible

set tags+=/usr/include/tags

" 不自動換行

"set nowrap

" 解決自動換行格式下, 如高度在折行之後超過視窗高度結果這一行看不到的問題

" set display=lastline

" 設定配色方案

colorscheme desert

" 搜尋字元

set incsearch

" 搜尋時忽略大小寫,但在有一個或以上大寫字母時仍大小寫敏感

set ignorecase

set smartcase

" 搜尋到檔案兩端時不重新搜尋

set nowrapscan

set guifont=Monospace\ Bold\ 12

"set guifont=Bold

"set guifont=11

"setlocal tabstop=4 softtabstop=4 shiftwidth=4 expandtab

set ts=4 sts=4 expandtab

" 設定 << 和 >> 指令移動時的寬度為 4

set shiftwidth=4

set list

set listchars=tab:▸\ ,eol:¬

"check file type

filetype on

"set background=dark

"智能自動縮進

set smartindent

"顯示括号配對情況

set showmatch

set ruler

" 設定指令行的行數為1

set cmdheight=1

"顯示狀态欄(預設值為1,無法顯示狀态欄)

set laststatus=2

" 設定在狀态行顯示的資訊

" set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]

set foldenable

"fold code by syntax 'cmd':

"set foldmethod=manual          "手工定義折疊

"set foldmethod=indent          "更多的縮進表示更進階别的折疊

"set foldmethod=expr            "用表達式來定義折疊

set foldmethod=syntax           "用文法加亮來定義折疊

"set foldmethod=diff            "對沒有更改的文本進行折疊

"set foldmethod=marker          "對文中的标志折疊

set foldcolumn=3

"set foldopen=all

"set foldclose=all

"對關閉的折疊的顔色的設定由 |hl-Folded| 決定。對折疊欄的顔色的設定由 |hl-FoldColumn| 決定。下面是設定顔色的例子:

highlight Folded guibg=grey guifg=blue

highlight FoldColumn guibg=darkgrey guifg=white

"設定顯示折疊文本

set foldtext=MyFoldText()

function MyFoldText()

let line = getline(v:foldstart)

let sub = substitute(line, '/\*\|\*/\|{{{\d\=', '', 'g')

return v:folddashes . sub

endfunction

"文法

set syntax=cpp

"set formatoptions=tc

"{{{plugin TagList.vim代碼導航

let Tlist_Ctags_Cmd='/usr/local/bin/ctags'

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

let Tlist_Show_One_File=1 "可同時展示多個檔案清單,1隻展示一個

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

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

let Tlist_Process_File_Always=1 "是否一直處理tags,1:處理,0:不處理

let Tlist_Inc_Winwidth=0

"let Tlist_Auto_Open=1 "vim啟動自動打開taglist

"let Tlist_Close_On_Select=1 "選擇tag後自動關閉taglist視窗

let Tlist_GainFocus_On_ToggleOpen=1 "打開tarlist後,焦點到taglist

map <F7> <Esc>:TlistToggle<CR>

"}}}

"{{{plugin NERDTree.vim

let NERDTreeWinPos=1

map <F3> <Esc>:NERDTree<CR>

"}}}

"{{{plugin DoxygenToolkit.vim 加注釋

let g:DoxygenToolkit_briefTag_pre="@Synopsis  "

let g:DoxygenToolkit_paramTag_pre="@Param "

let g:DoxygenToolkit_returnTag="@Returns   "

let g:DoxygenToolkit_blockHeader="--------------------------------------------------------------------------"

let g:DoxygenToolkit_blockFooter="----------------------------------------------------------------------------"

let g:DoxygenToolkit_authorName="Bad_boy"

let g:DoxygenToolkit_licenseTag="My own license <-- !!! Does not end with \<enter>"

"}}}

"Set mapleader

let mapleader = ","

"Fast reloading of the .vimrc

map <silent><leader>ss :source ~/.vimrc<cr>

"Fast editing of .vimrc

map <silent><leader>ee :vi ~/.vimrc<cr>

"When .vimrc is edited, reload it

autocmd! bufwritepost .vimrc source ~/.vimrc

"{{{plugin miniBufExpl

let g:miniBufExplMapWindowNavVim=1

let g:miniBufExplMapWindowNavArrows=1

let g:miniBufExplMapCTabSwitchBufs=1

let g:miniBufExplModSelTarget=1

"}}}"

"

" add by badboy 2012-1-2

if has("win32") || has("win95") || has("win64") || has("win16")

    let g:iswindows=1

else

    let g:iswindows=0

endif

if has("autocmd")

    filetype plugin indent on

endif

set nu

"if has("gui_running")

"    set guioptions-=m " 隐藏菜單欄

"    set guioptions-=T " 隐藏工具欄

"    set guioptions-=L " 隐藏左側滾動條

"    set guioptions-=r " 隐藏右側滾動條

"    set guioptions-=b " 隐藏底部滾動條

"    set showtabline=1 " 隐藏Tab欄

"endif

set guioptions+=L " 隐藏左側滾動條

set guioptions+=r " 隐藏右側滾動條

" 不自動換行

"set nowrap

" 解決自動換行格式下, 如高度在折行之後超過視窗高度結果這一行看不到的問題

" set display=lastline

" 設定配色方案

" colorscheme molokai

" 搜尋字元

set incsearch

" 搜尋時忽略大小寫,但在有一個或以上大寫字母時仍大小寫敏感

set ignorecase

set smartcase

" 搜尋到檔案兩端時不重新搜尋

set nowrapscan

"setlocal tabstop=4 softtabstop=4 shiftwidth=4 expandtab

set ts=4 sts=4 expandtab

" 設定 << 和 >> 指令移動時的寬度為 4

set shiftwidth=4

set list

set listchars=tab:▸\ ,eol:¬

"check file type

filetype on

"set background=dark

"智能自動縮進

set smartindent

"顯示括号配對情況

set showmatch

" 設定指令行的行數為1

set cmdheight=1

"顯示狀态欄(預設值為1,無法顯示狀态欄)

set laststatus=2

" 設定在狀态行顯示的資訊

" set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]

" 插入模式下上下左右移動光标

"inoremap <c-h> <left>

"inoremap <c-l> <right>

"inoremap <c-j> <c-o>gj

"inoremap <c-k> <c-o>gk

set foldenable

"fold code by syntax 'cmd':

"'zi' open/close all folds

"'za' open/close current fold

"'zM' close all folds

"'zR' open all folds

"當你退出檔案編輯時,手工折疊會被遺棄。要儲存折疊,使用 |:mkview|指令。之後要恢複可以使用 |:loadview|

"set foldmethod=manual          "手工定義折疊

"set foldmethod=indent          "更多的縮進表示更進階别的折疊

"set foldmethod=expr            "用表達式來定義折疊

set foldmethod=syntax           "用文法加亮來定義折疊

"set foldmethod=diff            "對沒有更改的文本進行折疊

"set foldmethod=marker          "對文中的标志折疊

"折疊欄

set foldcolumn=3

"set foldopen=all

"set foldclose=all

"對關閉的折疊的顔色的設定由 |hl-Folded| 決定。對折疊欄的顔色的設定由 |hl-FoldColumn| 決定。下面是設定顔色的例子:

highlight Folded guibg=grey guifg=blue

highlight FoldColumn guibg=darkgrey guifg=white

"設定顯示折疊文本

set foldtext=MyFoldText()

function MyFoldText()

let line = getline(v:foldstart)

let sub = substitute(line, '/\*\|\*/\|{{{\d\=', '', 'g')

return v:folddashes . sub

endfunction

"文法

set syntax=cpp

"set formatoptions=tc

"add header

function MyTitle()

    call setline(1,"")

endf

map <F9> <Esc>:call MyTitle()<CR><Esc>:$<Esc>o<Esc>

"add cpp framework

function CppFramework()

     call setline(7,"#include<iostream>")

     call setline(8,"#include<stdio.h>")

     call setline(9,"#include<fstream>")

     call setline(10,"using namespace std;")

     call setline(11,"")

     call setline(12,"int main(int argc, char* argv[])")

     call setline(13,"{")

     call setline(14," return 0;")

    call setline(15,"}")

endf

map <F2> <Esc>:call CppFramework()<CR><Esc>:$<Esc>2ko

"{{{add comment

function AddComment()

    if &syntax=="cpp" || &syntax=="c"

        execute "normal \<Esc>\<S-$>a\<TAB>\<Esc>2ha"

    elseif &syntax=="py"

        execute "normal \<Esc>\<S-$>a\<TAB>#\<Esc>2ha"

    elseif &syntax=="lua"

        execute "normal \<Esc>\<S-$>a\<TAB>--\<Esc>2ha"

    endif

endf

map <F4> <Esc>:call AddComment()<CR>i

function CommOneLine()

    let tmp=getline(".")

    call setline(line("."),"")

endf

map <F5> <Esc>:call CommOneLine()<CR><ESC>

"{{{plugin TagList.vim代碼導航

let Tlist_Ctags_Cmd='/usr/local/bin/ctags'

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

let Tlist_Show_One_File=0 "可同時展示多個檔案清單,1隻展示一個

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

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

let Tlist_Process_File_Always=1 "是否一直處理tags,1:處理,0:不處理

let Tlist_Inc_Winwidth=0

"let Tlist_Auto_Open=1 "vim啟動自動打開taglist

"let Tlist_Close_On_Select=1 "選擇tag後自動關閉taglist視窗

let Tlist_GainFocus_On_ToggleOpen=1 "打開tarlist後,焦點到taglist

"map <silent> <leader>tl :TlistToogle<CR>

map <F7> <Esc>:TlistToggle<CR>

"}}}

" {{{ plugin – winmove.vim 視窗移動

"let g:wm_move_left  = "<a-h>"

"let g:wm_move_right = "<a-l>"

"let g:wm_move_up    = "<a-k>"

"let g:wm_move_down  = "<a-j>"

"}}}

"Set mapleader

let mapleader = ","

"Fast reloading of the .vimrc

map <silent> <leader>ss :source ~/.vimrc<cr>

"Fast editing of .vimrc

map <silent> <leader>ee :gedit ~/.vimrc<cr>

"When .vimrc is edited, reload it

autocmd! bufwritepost .vimrc source ~/.vimrc