星期二, 7月 07, 2009

vimrc

突然想到自己的 .vimrc 雖然不怎麼值錢,但是不見了也很麻煩,所以備份一下好了。


syntax enable 
set number

""" set encoding to UTF-8
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,big5,euc-jp,gbk,euc-kr,utf-bom,iso8859-1
set termencoding=utf-8
set ambiwidth=double

""" set color scheme
set background=dark
set t_Co=256
color yen3

set title
set showmode            " Show current input mode in status line
set cursorline         " Show Cursor Line in Underline
"set showtabline=2
set wildmenu " Show autocomplete menus.
set visualbell

""" enable mouse
set mouse=a
set ttymouse=xterm
set mousemodel=extend

""" Search Setting
set showcmd
set incsearch
set showmatch

set hls

""" Backup Setting
set backup
set backupdir=$HOME/.vim/backup

""" set status bar
set laststatus=2
set statusline=%4*%<\ %1*[%F]
set statusline+=%4*\ %5*[%{&encoding}, " encoding
set statusline+=%{&fileformat}]%m " file format
set statusline+=%4*%=\ %6*%y%4*\ %3*%l%4*,\ %3*%c%4*\ \<\ %2*%P%4*\ \>
highlight User1 ctermfg=red
highlight User2 term=underline cterm=underline ctermfg=green
highlight User3 term=underline cterm=underline ctermfg=yellow
highlight User4 term=underline cterm=underline ctermfg=white
highlight User5 ctermfg=cyan
highlight User6 ctermfg=white

""" set folding
set foldnestmax=3
"set foldmethod=syntax
"set foldcolumn=4

""" Set editing Tab
set autoindent
set expandtab
set shiftwidth=4
set softtabstop=8
set tabstop=4
set smarttab
set backspace=indent,eol,start 

""" set help doc
helptags $HOME/.vim/doc 

filetype on
filetype plugin on

""" Key Mapping
nnoremap <silent> <f2> :NERDTree<cr>
nnoremap <silent> <f3> :TlistToggle<cr>
nnoremap <silent> <f6> :set foldmethod=syntax<cr>
nnoremap <silent> <f7> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<cr>

nmap cr=    $F=lcf;
nmap cl=    $F=hc^

nmap <LEADER>tc :tabnew<CR>
nmap <LEADER>te :tabedit<SPACE>
nmap <LEADER>tm :tabmove<SPACE>
nmap <LEADER>tk :tabclose<CR>
nmap <C-H> :tabprev<CR>
nmap <C-L> :tabnext<CR>

""" 讓我們可以使用 tab 來縮排
nmap <tab> v>
nmap <s-tab> v<
vmap <tab> >gv
vmap <s-tab> <gv

""" let command mode has bash key binding
cmap <c-a> <home>
cmap <c-e> <end>
cnoremap <c-b> <left>
cnoremap <c-d> <del>
cnoremap <c-f> <right>
cnoremap <c-n> <down>
cnoremap <c-p> <up>
cnoremap <esc><c-b> <s-left>
cnoremap <esc><c-f> <s-right>

""" Source Code Formating
let OmniCpp_MayCompleteScope = 1
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview


""" Tab setting
autocmd TabLeave * let g:LastUsedTabPage = tabpagenr()
function! SwitchLastUsedTab()
    if exists("g:LastUsedTabPage")
        execute "tabnext " g:LastUsedTabPage
    endif
endfunction
nmap tt :call SwitchLastUsedTab()<CR>

""" Auto remove each line-end space 
autocmd FileType c,cpp,java,php,perl,python,ruby,sh,v autocmd BufWritePre  :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")'))


com! -bang -nargs=? QFix cal QFixToggle(<bang>0)
fu! QFixToggle(forced)
    if exists("g:qfix_win") && a:forced == 0
        cclose
        unlet g:qfix_win
    else
        copen 10
        let g:qfix_win = bufnr("$")
        en
    endf
nn <leader>m :make<cr>
nn <leader>q :QFix<cr>

nmap <C-c><C-c> :!g++ -g -Wall % -o %:r.out<CR>

---
也可以當成參考 XD

沒有留言: