.vimrc 整理中

set runtimepath+=~/vimfiles

syntax on
filetype on
filetype plugin on
filetype indent on

set nonu

colorscheme torte

set nobackup

" バッファが編集中でもその他のファイルを開けるように
set hidden

set scrolloff=3

set ambiwidth=double

" タブをわかりやすく
set list
set listchars=tab:>.

" backspace をまともに
set backspace=indent,eol,start

set smartindent


" -------------------
"  検索
" -------------------
set ignorecase
set smartcase
set wrapscan
set noincsearch
set hlsearch
set showmatch


" -----------------
"  ステータス, コマンド
" -----------------
set cmdheight=2
set laststatus=2
"ステータス部の書式設定(詳細は後述)
set statusline=%y%{GetStatusEx()}%F%m%r%=<%l-%c(%p%%)>

" 文字エンコーディング&改行コード取得関数。
" http://www.seeds-man.com/~nari/v2/people/nari/comp/linux/vim1.shtml
function! GetStatusEx()
	let str = ''
	let str = str . '[' . &fileformat . ']'
	if has('multi_byte') && &fileencoding != ''
		let str = '[' . &fileencoding . '] :' . str
	endif
	return str
endfunction

" コマンドライン補間をシェルっぽく
set wildmode=list:longest


" ----------------
" キーマップ
" ----------------
nmap j gj
nmap k gk
vmap j gj
vmap k gk

" 検索ハイライト一時消去
nnoremap  gh :nohlsearch<Return>

" 辞書補完
autocmd FileType javascript :set dictionary=~/vimfiles/dic/js.dict

"omnifunc complete
setlocal omnifunc=syntaxcomplete#Complete
autocmd FileType javascript :set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType css :set omnifunc=csscomplete#CompleteCSS
autocmd FileType html :set omnifunc=htmlcomplete#CompleteTags

"補完のときにでるヤツの色
highlight Pmenu ctermbg=black ctermfg=22
highlight Pmenusel term=standout ctermbg=22

" ファイルを実行
function! ShebangExecute()
  let m = matchlist(getline(1), '#!\(.*\)')
  if(len(m) > 2)
    execute '!'. m[1] . ' %'
  else
    execute '!' &ft ' %'
  endif
endfunction
nmap ,e :call ShebangExecute()<CR>


" template
autocmd BufNewFile *.user.js 0r ~/vimfiles/templates/skel.js
autocmd BufNewFile *.pl 0r ~/vimfiles/templates/skel.pl
autocmd BufNewFile *.html,*.htm 0r ~/vimfiles/templates/skel.html
autocmd bufnewfile *.rb 0r ~/vimfiles/templates/skel.rb

autocmd BufNewFile,BufRead *.io set filetype=io
autocmd BufNewFile,BufRead *.as set filetype=actionscript
autocmd BufNewFile,BufRead *.yaml,*.yml so ~/vimfiles/syntax/yaml.vim

au FileType ruby call RubySetting()
function! RubySetting()
  setlocal ts=2 sts=2 sw=2
  setlocal et
  iabbrev edn end
endfunction


" -----------------------
"  Settings for plugins
" -----------------------
" surrund.vim
let g:surround_{char2nr('f')} = "function \1function\1 () { \r }"

" MiniBufExplorer
let mapleader = "^F" 
nmap <Space> :MBEbn<CR>
nmap ,1 :e #1<CR>
nmap ,2 :e #2<CR>
nmap ,3 :e #3<CR>
nmap ,4 :e #4<CR>
nmap ,5 :e #5<CR>
nmap ,6 :e #6<CR>
nmap ,7 :e #7<CR>
nmap ,8 :e #8<CR>
nmap ,9 :e #9<CR>

" yankring.vim
nmap ,y :YRShow<CR>

" MRU.vim
nmap ,h :MRU<CR>
:let MRU_Max_Entries=30