.vimrc_noplugin 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. " coding:utf-8
  2. " ζ*'ヮ')ζ ζ(*'ヮ'リ+
  3. "
  4. set ignorecase
  5. set smartcase
  6. set tabstop=2
  7. set expandtab
  8. set autoindent
  9. set backspace=2
  10. set wrapscan
  11. set showmatch
  12. set wildmenu
  13. set formatoptions+=mM
  14. "set softtabstop=2
  15. set shiftwidth=4
  16. set fileencodings=utf-8,sjis,cp932,euc-jp,default,latin
  17. set number
  18. set ruler
  19. set nolist
  20. set wrap
  21. set laststatus=2
  22. set cmdheight=2
  23. set showcmd
  24. set title
  25. set hlsearch
  26. colorscheme elflord
  27. syntax on
  28. " ファイル名に大文字小文字の区別がないシステム用の設定:
  29. " (例: DOS/Windows/MacOS)
  30. "
  31. if filereadable($VIM . '/vimrc') && filereadable($VIM . '/ViMrC')
  32. " tagsファイルの重複防止
  33. set tags=./tags,tags
  34. endif
  35. " コンソールでのカラー表示のための設定(暫定的にUNIX専用)
  36. if has('unix') && !has('gui_running')
  37. let uname = system('uname')
  38. if uname =~? "linux"
  39. set term=builtin_linux
  40. elseif uname =~? "freebsd"
  41. set term=builtin_cons25
  42. elseif uname =~? "Darwin"
  43. set term=beos-ansi
  44. else
  45. set term=builtin_xterm
  46. endif
  47. unlet uname
  48. endif
  49. " コンソール版で環境変数$DISPLAYが設定されていると起動が遅くなる件へ対応
  50. if !has('gui_running') && has('xterm_clipboard')
  51. set clipboard=exclude:cons\\\|linux\\\|cygwin\\\|rxvt\\\|screen
  52. endif
  53. " タブページの切り替えをWindowsのように
  54. " CTRL+Tab SHIFT+Tabで行うように.
  55. if v:version >= 700
  56. nnoremap <C-Tab> gt
  57. nnoremap <C-S-Tab> gT
  58. endif
  59. if has('+regexpengine')
  60. set re=0
  61. endif
  62. set nocompatible
  63. set ww+=h,l,>,<,[,]
  64. set mouse=a
  65. set ttymouse=xterm2
  66. set clipboard=unnamedplus
  67. " ,vr: .vimrc
  68. nnoremap <silent> ,vr :tabnew ~/.vimrc<CR>
  69. nnoremap <silent> ,so :so ~/.vimrc<CR>
  70. nnoremap <Esc><Esc> :nohlsearch<CR><ESC>
  71. nnoremap <silent> ,ts :<C-u>tab stj <C-R>=expand('<cword>')<CR><CR>
  72. "tabで補完候補の選択を行う
  73. inoremap <expr><TAB> pumvisible() ? "\<Down>" : "\<TAB>"
  74. inoremap <expr><S-TAB> pumvisible() ? "\<Up>" : "\<S-TAB>"
  75. let g:netrw_nogx = 1
  76. augroup vimrc
  77. autocmd!
  78. augroup END
  79. function! s:SID_PREFIX()
  80. return matchstr(expand('<sfile>'), '<SNR>\d\+_')
  81. endfunction
  82. set titlelen=100
  83. set guioptions-=e
  84. autocmd vimrc BufEnter * let &titlestring = '%{' . s:SID_PREFIX() . 'titlestring()}'
  85. autocmd vimrc User plugin-lingr-unread let &titlestring = '%{' . s:SID_PREFIX() . 'titlestring()}'
  86. if exists('$TMUX') || exists('$WINDOW')
  87. set t_ts=k
  88. set t_fs=\
  89. endif
  90. function! s:titlestring()
  91. if &filetype =~ '^lingr'
  92. let &titlestring = 'lingr: ' . lingr#unread_count()
  93. else
  94. let &titlestring = bufname('')
  95. endif
  96. endfunction
  97. " tabline
  98. set showtabline=2 " always show tabline
  99. let &tabline = '%!' . s:SID_PREFIX() . 'tabline()'
  100. function! s:tabline()
  101. " show each tab
  102. let s = ''
  103. for i in range(1, tabpagenr('$'))
  104. let list = tabpagebuflist(i)
  105. let nr = tabpagewinnr(i)
  106. let current_tabnr = tabpagenr()
  107. "let title = bufname('')
  108. if i == current_tabnr
  109. let title = fnamemodify(getcwd(), ':t') . '/'
  110. "let title = bufname('')
  111. else
  112. let title = fnamemodify(gettabvar(i, 'cwd'), ':t') . '/'
  113. endif
  114. let title = empty(title) ? '[No Name]' : title
  115. let s .= i == current_tabnr ? '%#TabLineSel#' : '%#TabLine#'
  116. let s .= '%' . i . 'T[' . i . '] ' . title
  117. let s .= ' '
  118. endfor
  119. " show lingr unread count
  120. let lingr_unread = ""
  121. if exists('*lingr#unread_count')
  122. let lingr_unread_count = lingr#unread_count()
  123. if lingr_unread_count > 0
  124. let lingr_unread = "%#ErrorMsg#(" . lingr_unread_count . ")"
  125. elseif lingr_unread_count == 0
  126. let lingr_unread = "()"
  127. endif
  128. endif
  129. " build tabline
  130. let s .= '%#TabLineFill#%T%=%<[' . getcwd() . ']' . lingr_unread
  131. return s
  132. endfunction
  133. autocmd vimrc BufNewFile,BufRead *.tsv set noexpandtab wrap tabstop=4 shiftwidth=4
  134. autocmd vimrc BufNewFile,BufRead *.php set noexpandtab wrap tabstop=4 shiftwidth=4
  135. autocmd vimrc BufNewFile,BufRead *.php set tags+=$HOME/ctags/php.tags
  136. augroup vimrc-scratch-buffer
  137. autocmd!
  138. " Make a scratch buffer when unnamed buffer.
  139. autocmd BufEnter * call s:scratch_buffer()
  140. autocmd FileType qfreplace autocmd! vimrc-scratch * <buffer>
  141. function! s:scratch_buffer()
  142. if exists('b:scratch_buffer') || bufname('%') !=# '' || &l:buftype !=# ''
  143. return
  144. endif
  145. let b:scratch_buffer = 1
  146. setlocal buftype=nofile nobuflisted noswapfile bufhidden=hide
  147. augroup vimrc-scratch
  148. autocmd! * <buffer>
  149. autocmd BufWriteCmd <buffer> call s:scratch_on_BufWriteCmd()
  150. augroup END
  151. endfunction
  152. function! s:scratch_on_BufWriteCmd()
  153. silent! setl buftype< buflisted< swapfile< bufhidden< nomodified
  154. autocmd! vimrc-scratch * <buffer>
  155. if bufname('%') ==# '' && exists('b:scratch_buffer')
  156. execute 'saveas' . (v:cmdbang ? '!' : '') ' <afile>'
  157. filetype detect
  158. endif
  159. unlet! b:scratch_buffer
  160. endfunction
  161. augroup END