Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- syntax on
- set fileencodings=utf-8,big5,ucs-bom,iso8859-1
- set termencoding=utf-8
- set encoding=utf-8
- set shiftwidth=4
- set tabstop=4
- set expandtab
- set nocompatible
- set hlsearch
- set autoindent
- set nonumber
- set tabpagemax=20
- "set paste
- "set mouse=a
- set tags=./tags,./TAGS,tags,TAGS,~/.tags
- " status bar
- set laststatus=2
- set statusline=%4*%<\ %1*[%F]
- set statusline+=%4*\ %5*[%{&fileencoding}, " 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
- " taglist plugin
- nnoremap <silent> <F2> :TlistToggle<CR>
- " changelog hotkey '\' 'o'
- if $USER == "sylee"
- let changelog_username = "Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>"
- endif
- nmap <F3> :set list!<BAR>set list?<CR>
- nmap <F4> :set nu!<BAR>set nu?<CR>
- nmap <F5> :set wrap!<BAR>set nowrap?<CR>
- nmap <F6> :set hls!<BAR>set hls?<CR>
- nmap <F7> :set paste!<BAR>set paste?<CR>
- nmap <F8> :marks<CR>
- nmap <F9> :registers<CR>
- nmap <F10> :map<CR>
- " tab view switch
- nmap <C-Right> :tabnext<CR>
- nmap <C-Left> :tabprevious<CR>
- " Yahoo dictionary
- nmap <C-Y> viwy:!ydict <C-R>"<CR>
- " devhelp
- nmap <C-K> viwy:!devhelp -s <C-R>"<CR>
- " expandtab switch
- nmap <C-J> :set expandtab!<BAR>set expandtab?<CR>
- " ctags plugin
- nmap g+ viwy:tab ts <C-R>"<CR>
- nmap g- viwy:pts <C-R>"<CR>
- nmap g= viwy:sts <C-R>"<CR>
- nmap g<Bar> viwy:vsplit<CR>:ts <C-R>"<CR>
- " vimgrep for keyword
- nmap g* :exec 'vimgrep /\<'.expand('<cword>').'\>/g **/*.[ch] **/*.[ch]pp **/*.java **/*.p[ly] **/*.rb **/*.vala'<CR>
- " cursor highlight
- set cursorline
- highlight CursorLine cterm=NONE ctermbg=Black
- autocmd InsertEnter * set nocursorline
- autocmd InsertLeave * set cursorline
- nmap <S-F11> :set cursorline!<BAR>set nocursorline?<CR>
- nmap <S-F12> :set cursorcolumn!<BAR>set nocursorcolumn?<CR>
- "" global plugin
- " search for definition
- nmap <C-F5> :GtagsCursor<CR>
- " search for reference
- nmap <C-F6> viwy:Gtags -r <C-R>"<CR>
- nmap <C-F7> :Gozilla<CR>
- nmap <C-F8> :!gtags<CR>
- " ctags plugin
- nmap <C-F9> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
- " transfer html unicode
- nmap <C-F10> :%s/&#\([0-9]\+\);/\=nr2char(submatch(1))/g<CR>
- " quickfix
- nmap <C-n> :cn<CR>
- nmap <C-p> :cp<CR>
- hi FoldColumn term=standout cterm=bold ctermfg=darkgreen ctermbg=black
- hi Folded term=standout cterm=bold ctermfg=darkyellow ctermbg=black
- hi Search term=standout cterm=bold ctermfg=yellow ctermbg=black
- ia pk fprintf(stderr, " (\033[01;32mTRACE\033[00m) \033[01;35m%s +%d %s \033[00m\n", __FILE__, __LINE__, __FUNCTION__);
- " Session:
- function! AutoLoadSession()
- let g:sessionfile = getcwd() . "/Session.vim"
- if (argc() == 0 && filereadable(g:sessionfile))
- echohl WarningMsg
- echo "Session file exists. Load this? (y/n): "
- echohl None
- while 1
- let c = getchar()
- if c == char2nr("y")
- source Session.vim
- return
- elseif c == char2nr("n")
- return
- endif
- endwhile
- endif
- endfunction
- function! AutoSaveSession()
- if exists(g:sessionfile)
- execute "mks! " . g:sessionfile
- endif
- endfunction
- augroup AutoLoadSettion
- autocmd!
- autocmd VimEnter * call AutoLoadSession()
- autocmd VimLeave * call AutoSaveSession()
- augroup END
- function GetPerlFold()
- if getline(v:lnum) =~ '^\v(sub|template|\=\w+)\s\S+'
- return '>1'
- elseif getline(v:lnum) =~ '^\v(\};?|\=cut)\s*$'
- return '<1'
- elseif getline(v:lnum) =~ '^\s*#.*{{{'
- return 'a1'
- elseif getline(v:lnum) =~ '^\s*#.*}}}'
- return 's1'
- else
- return "="
- endif
- endfunction
- function s:indent_folding()
- setlocal foldmethod=indent foldcolumn=4 foldnestmax=3 foldlevel=3
- endfunction
- function s:syntax_folding()
- setlocal foldmethod=syntax foldcolumn=4 foldnestmax=3 foldlevel=3
- endfunction
- function FoldText()
- let line = getline(v:foldstart)
- let cms = &commentstring
- let cms = substitute( cms , '%s' , '|' , 'g' )
- let cms = substitute( cms , '[*<!>]' , '\\\0' , 'g' )
- let cms = '\v(' . cms
- if cms =~ '|$'
- else
- let cms .= '|'
- endif
- let cms .= '\{\{\{\d=)'
- " strip commentstring
- if line =~ cms
- let sub = substitute( line, cms , '', 'g')
- " strip prefix
- elseif line =~ '^\v(sub|template)\s'
- let sub = substitute( line, '^\v(sub|template)\s''?(\w+)''?.*','\1: \2','')
- elseif line =~ '^\v\=(\w+)\s'
- let sub = substitute( line, '^\v\=(\w+)\s(\w+)','pod: (\1) \2','')
- else
- let sub = line
- endif
- " strip space
- let sub = substitute( sub, '^\s*' , '', 'g')
- let sub = substitute( sub, '\s*$' , '', 'g')
- " count line
- let num = v:foldend - v:foldstart
- " make format line
- let fline = printf( "|%3d|- %s " , v:foldend - v:foldstart ,sub )
- "return fold
- return v:folddashes . v:folddashes . v:folddashes . fline
- endfunction
- function s:java_custom()
- setlocal tabstop=8 expandtab shiftwidth=4 textwidth=80
- call s:syntax_folding()
- endfunction
- function s:perl_custom()
- setlocal foldmethod=expr foldcolumn=2 foldlevel=1
- setlocal foldexpr=GetPerlFold()
- setlocal foldtext=FoldText()
- "let perl_fold=1
- "let perl_fold_blocks=1
- function! s:man(keyword)
- execute '!perldoc ' . a:keyword
- endfunction
- command! -nargs=1 Man call s:man(<f-args>)
- noremap K :!perldoc <cword> <bar><bar> perldoc -f <cword><cr>
- endfunction
- function s:python_custom()
- setlocal tabstop=4 expandtab shiftwidth=4
- call s:indent_folding()
- function! s:man(keyword)
- execute '!pydoc ' . a:keyword
- endfunction
- command! -nargs=1 Man call s:man(<f-args>)
- cnoremap K :!pydoc <cword><CR>
- endfunction
- if has("autocmd")
- " Strip tailing white space
- autocmd FileType c,cpp,java,php,perl,python,ruby,sh,automake autocmd BufWritePre <buffer> :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")'))
- autocmd FileType automake set expandtab
- autocmd FileType c,cpp call s:syntax_folding()
- autocmd FileType java call s:java_custom()
- autocmd FileType perl call s:perl_custom()
- autocmd FileType python call s:python_custom()
- autocmd FileType sh,vim,xml call s:indent_folding()
- "autocmd BufNewFile *.c 0read ~/Ubuntu\ One/sylee/Skel/c.c
- "autocmd BufNewFile *.cc 0read ~/Ubuntu\ One/sylee/Skel/cpp.cc
- "autocmd BufNewFile *.py 0read ~/Ubuntu\ One/sylee/Skel/python.py
- "autocmd BufNewFile *.pl 0read ~/Ubuntu\ One/sylee/Skel/perl.pl
- "autocmd BufNewFile *.cpp 0read ~/Ubuntu\ One/sylee/Skel/cpp.cc
- au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
- filetype plugin indent on
- " Vala Support
- autocmd BufRead *.vala set efm=%f:%l.%c-%[%^:]%#:\ %t%[%^:]%#:\ %m
- autocmd BufRead *.vapi set efm=%f:%l.%c-%[%^:]%#:\ %t%[%^:]%#:\ %m
- autocmd BufRead,BufNewFile *.vala setfiletype vala
- autocmd BufRead,BufNewFile *.vapi setfiletype vala
- endif
Add Comment
Please, Sign In to add comment