Guest User

Untitled

a guest
Jul 17th, 2018
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.83 KB | None | 0 0
  1. syntax on
  2.  
  3. set fileencodings=utf-8,big5,ucs-bom,iso8859-1
  4. set termencoding=utf-8
  5. set encoding=utf-8
  6. set shiftwidth=4
  7. set tabstop=4
  8. set expandtab
  9. set nocompatible
  10. set hlsearch
  11. set autoindent
  12. set nonumber
  13. set tabpagemax=20
  14. "set paste
  15. "set mouse=a
  16. set tags=./tags,./TAGS,tags,TAGS,~/.tags
  17.  
  18. " status bar
  19. set laststatus=2
  20. set statusline=%4*%<\ %1*[%F]
  21. set statusline+=%4*\ %5*[%{&fileencoding}, " encoding
  22. set statusline+=%{&fileformat}]%m " file format
  23. set statusline+=%4*%=\ %6*%y%4*\ %3*%l%4*,\ %3*%c%4*\ \<\ %2*%P%4*\ \>
  24. highlight User1 ctermfg=red
  25. highlight User2 term=underline cterm=underline ctermfg=green
  26. highlight User3 term=underline cterm=underline ctermfg=yellow
  27. highlight User4 term=underline cterm=underline ctermfg=white
  28. highlight User5 ctermfg=cyan
  29. highlight User6 ctermfg=white
  30.  
  31. " taglist plugin
  32. nnoremap <silent> <F2> :TlistToggle<CR>
  33.  
  34. " changelog hotkey '\' 'o'
  35. if $USER == "sylee"
  36. let changelog_username = "Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>"
  37. endif
  38.  
  39. nmap <F3> :set list!<BAR>set list?<CR>
  40. nmap <F4> :set nu!<BAR>set nu?<CR>
  41. nmap <F5> :set wrap!<BAR>set nowrap?<CR>
  42. nmap <F6> :set hls!<BAR>set hls?<CR>
  43. nmap <F7> :set paste!<BAR>set paste?<CR>
  44.  
  45. nmap <F8> :marks<CR>
  46. nmap <F9> :registers<CR>
  47. nmap <F10> :map<CR>
  48.  
  49. " tab view switch
  50. nmap <C-Right> :tabnext<CR>
  51. nmap <C-Left> :tabprevious<CR>
  52.  
  53. " Yahoo dictionary
  54. nmap <C-Y> viwy:!ydict <C-R>"<CR>
  55.  
  56. " devhelp
  57. nmap <C-K> viwy:!devhelp -s <C-R>"<CR>
  58.  
  59. " expandtab switch
  60. nmap <C-J> :set expandtab!<BAR>set expandtab?<CR>
  61.  
  62. " ctags plugin
  63. nmap g+ viwy:tab ts <C-R>"<CR>
  64. nmap g- viwy:pts <C-R>"<CR>
  65. nmap g= viwy:sts <C-R>"<CR>
  66. nmap g<Bar> viwy:vsplit<CR>:ts <C-R>"<CR>
  67.  
  68. " vimgrep for keyword
  69. nmap g* :exec 'vimgrep /\<'.expand('<cword>').'\>/g **/*.[ch] **/*.[ch]pp **/*.java **/*.p[ly] **/*.rb **/*.vala'<CR>
  70.  
  71. " cursor highlight
  72. set cursorline
  73. highlight CursorLine cterm=NONE ctermbg=Black
  74. autocmd InsertEnter * set nocursorline
  75. autocmd InsertLeave * set cursorline
  76. nmap <S-F11> :set cursorline!<BAR>set nocursorline?<CR>
  77. nmap <S-F12> :set cursorcolumn!<BAR>set nocursorcolumn?<CR>
  78.  
  79. "" global plugin
  80. " search for definition
  81. nmap <C-F5> :GtagsCursor<CR>
  82. " search for reference
  83. nmap <C-F6> viwy:Gtags -r <C-R>"<CR>
  84. nmap <C-F7> :Gozilla<CR>
  85. nmap <C-F8> :!gtags<CR>
  86.  
  87. " ctags plugin
  88. nmap <C-F9> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
  89.  
  90. " transfer html unicode
  91. nmap <C-F10> :%s/&#\([0-9]\+\);/\=nr2char(submatch(1))/g<CR>
  92.  
  93. " quickfix
  94. nmap <C-n> :cn<CR>
  95. nmap <C-p> :cp<CR>
  96.  
  97. hi FoldColumn term=standout cterm=bold ctermfg=darkgreen ctermbg=black
  98. hi Folded term=standout cterm=bold ctermfg=darkyellow ctermbg=black
  99. hi Search term=standout cterm=bold ctermfg=yellow ctermbg=black
  100.  
  101. ia pk fprintf(stderr, " (\033[01;32mTRACE\033[00m) \033[01;35m%s +%d %s \033[00m\n", __FILE__, __LINE__, __FUNCTION__);
  102.  
  103. " Session:
  104. function! AutoLoadSession()
  105. let g:sessionfile = getcwd() . "/Session.vim"
  106. if (argc() == 0 && filereadable(g:sessionfile))
  107. echohl WarningMsg
  108. echo "Session file exists. Load this? (y/n): "
  109. echohl None
  110. while 1
  111. let c = getchar()
  112. if c == char2nr("y")
  113. source Session.vim
  114. return
  115. elseif c == char2nr("n")
  116. return
  117. endif
  118. endwhile
  119. endif
  120. endfunction
  121.  
  122. function! AutoSaveSession()
  123. if exists(g:sessionfile)
  124. execute "mks! " . g:sessionfile
  125. endif
  126. endfunction
  127.  
  128. augroup AutoLoadSettion
  129. autocmd!
  130. autocmd VimEnter * call AutoLoadSession()
  131. autocmd VimLeave * call AutoSaveSession()
  132. augroup END
  133.  
  134. function GetPerlFold()
  135. if getline(v:lnum) =~ '^\v(sub|template|\=\w+)\s\S+'
  136. return '>1'
  137. elseif getline(v:lnum) =~ '^\v(\};?|\=cut)\s*$'
  138. return '<1'
  139. elseif getline(v:lnum) =~ '^\s*#.*{{{'
  140. return 'a1'
  141. elseif getline(v:lnum) =~ '^\s*#.*}}}'
  142. return 's1'
  143. else
  144. return "="
  145. endif
  146. endfunction
  147.  
  148. function s:indent_folding()
  149. setlocal foldmethod=indent foldcolumn=4 foldnestmax=3 foldlevel=3
  150. endfunction
  151.  
  152. function s:syntax_folding()
  153. setlocal foldmethod=syntax foldcolumn=4 foldnestmax=3 foldlevel=3
  154. endfunction
  155.  
  156. function FoldText()
  157. let line = getline(v:foldstart)
  158. let cms = &commentstring
  159.  
  160. let cms = substitute( cms , '%s' , '|' , 'g' )
  161. let cms = substitute( cms , '[*<!>]' , '\\\0' , 'g' )
  162. let cms = '\v(' . cms
  163. if cms =~ '|$'
  164. else
  165. let cms .= '|'
  166. endif
  167. let cms .= '\{\{\{\d=)'
  168.  
  169. " strip commentstring
  170. if line =~ cms
  171. let sub = substitute( line, cms , '', 'g')
  172. " strip prefix
  173. elseif line =~ '^\v(sub|template)\s'
  174. let sub = substitute( line, '^\v(sub|template)\s''?(\w+)''?.*','\1: \2','')
  175. elseif line =~ '^\v\=(\w+)\s'
  176. let sub = substitute( line, '^\v\=(\w+)\s(\w+)','pod: (\1) \2','')
  177. else
  178. let sub = line
  179. endif
  180.  
  181. " strip space
  182. let sub = substitute( sub, '^\s*' , '', 'g')
  183. let sub = substitute( sub, '\s*$' , '', 'g')
  184.  
  185. " count line
  186. let num = v:foldend - v:foldstart
  187.  
  188. " make format line
  189. let fline = printf( "|%3d|- %s " , v:foldend - v:foldstart ,sub )
  190.  
  191. "return fold
  192. return v:folddashes . v:folddashes . v:folddashes . fline
  193. endfunction
  194.  
  195. function s:java_custom()
  196. setlocal tabstop=8 expandtab shiftwidth=4 textwidth=80
  197. call s:syntax_folding()
  198. endfunction
  199.  
  200. function s:perl_custom()
  201. setlocal foldmethod=expr foldcolumn=2 foldlevel=1
  202. setlocal foldexpr=GetPerlFold()
  203. setlocal foldtext=FoldText()
  204. "let perl_fold=1
  205. "let perl_fold_blocks=1
  206. function! s:man(keyword)
  207. execute '!perldoc ' . a:keyword
  208. endfunction
  209. command! -nargs=1 Man call s:man(<f-args>)
  210. noremap K :!perldoc <cword> <bar><bar> perldoc -f <cword><cr>
  211. endfunction
  212.  
  213. function s:python_custom()
  214. setlocal tabstop=4 expandtab shiftwidth=4
  215. call s:indent_folding()
  216. function! s:man(keyword)
  217. execute '!pydoc ' . a:keyword
  218. endfunction
  219. command! -nargs=1 Man call s:man(<f-args>)
  220. cnoremap K :!pydoc <cword><CR>
  221. endfunction
  222.  
  223. if has("autocmd")
  224. " Strip tailing white space
  225. autocmd FileType c,cpp,java,php,perl,python,ruby,sh,automake autocmd BufWritePre <buffer> :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")'))
  226. autocmd FileType automake set expandtab
  227. autocmd FileType c,cpp call s:syntax_folding()
  228. autocmd FileType java call s:java_custom()
  229. autocmd FileType perl call s:perl_custom()
  230. autocmd FileType python call s:python_custom()
  231. autocmd FileType sh,vim,xml call s:indent_folding()
  232. "autocmd BufNewFile *.c 0read ~/Ubuntu\ One/sylee/Skel/c.c
  233. "autocmd BufNewFile *.cc 0read ~/Ubuntu\ One/sylee/Skel/cpp.cc
  234. "autocmd BufNewFile *.py 0read ~/Ubuntu\ One/sylee/Skel/python.py
  235. "autocmd BufNewFile *.pl 0read ~/Ubuntu\ One/sylee/Skel/perl.pl
  236. "autocmd BufNewFile *.cpp 0read ~/Ubuntu\ One/sylee/Skel/cpp.cc
  237.  
  238. au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
  239. filetype plugin indent on
  240.  
  241. " Vala Support
  242. autocmd BufRead *.vala set efm=%f:%l.%c-%[%^:]%#:\ %t%[%^:]%#:\ %m
  243. autocmd BufRead *.vapi set efm=%f:%l.%c-%[%^:]%#:\ %t%[%^:]%#:\ %m
  244. autocmd BufRead,BufNewFile *.vala setfiletype vala
  245. autocmd BufRead,BufNewFile *.vapi setfiletype vala
  246. endif
Add Comment
Please, Sign In to add comment