syntax on
set tabstop=8
set shiftwidth=2
" set fileencodings=iso-2022-jp-3,iso-2022-jp,euc-jisx0213,euc-jp,utf-8,usc-bom,ucs-2le,ucs-2,euc-jp,euc-jp-ms,cp932
" set fileencoding=euc-jp (export LANG=ja_JP.eucJP)
" set fileencoding=utf-8 (export LANG=ja_JP.UTF-8)
" set encoding=sjis (export LANG=ja_JP.SJIS)
set autoindent
set backspace=indent,eol,start
set ignorecase
set smartcase
set magic
set wrapscan
set hlsearch
set smartcase
set nowrap
set nolinebreak
set textwidth=0
set formatoptions=q
set ambiwidth=double
set nu
set title
set showmatch
set matchtime=2
set incsearch
set wildmenu wildmode=list:full
set laststatus=2
set statusline=%<%f\ %m%r%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%=%l/%L,%v
set whichwrap=b,s,[,],<,>,~
" TOhtml 設定
let html_use_css=1
let html_use_encoding="utf-8"
" [手順]
" :TOhtml
" :set fenc=utf-8
" :w
" <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">


" http://www.atmarkit.co.jp/flinux/rensai/vim08/08c.html
let s:quickfixwindow = "close"
function! b:openCloseQuickfix()
if "open" ==? s:quickfixwindow
let s:quickfixwindow = "close"
cclose
else
let s:quickfixwindow = "open"
copen
endif
endfunction
nmap <silent> <F2> :call b:openCloseQuickfix()<CR>
imap <silent> <F2> <C-o>:call b:openCloseQuickfix()<CR>
nmap <silent> <F7> :update<CR>:e .<CR>
imap <silent> <F7> <ESC>:update<CR>:e .<CR>
vmap <silent> <F7> <ESC>:update<CR>:e .<CR>
cmap <silent> <F7> <ESC>:update>CR>:e .<CR>
nmap <F8> :bd<CR>
imap <F8> <ESC> :bd<CR>
" vimdiff command
" nmap <F9> [c<CR>
" imap <F9> <ESC> [c<CR>
" nmap <F10> ]c<CR>
" imap <F10> <ESC> ]c<CR>
" nmap <F11> :diffget<CR>
" imap <F11> <ESC> :diffget<CR>
" nmap <F12> :diffput<CR>
" imap <F12> <ESC> :diffput<CR>
" ファイルのフォルダをカレントディレクトリにする
" au BufEnter * execute ":lcd " . expand("%:p:h")
" 常に開いているファイルと同じディレクトリをカレントディレクトリにする
" augroup group_vimrc_cd
" autocmd!
" autocmd BufEnter * execute ":lcd " . (isdirectory(expand("%:p:h")) ? expand("%:p:h") : "")
" augroup END
" 開いているファイルパスに移動
" cd %:h
" #8 のファイルパスに移動
" cd #8:p:h
" 検索のハイライトを消す
nnoremap <Esc><Esc> :nohlsearch<CR>
" Shiftキーによる範囲選択
nnoremap <S-Left> v<Left>
nnoremap <S-Home> v<Home>
noremap! <S-Left> <Left><C-O>v
noremap! <S-Home> <Left><C-O>v<Home>
vnoremap <S-Left> <Left>
nnoremap <S-Right> v<Right>
nnoremap <S-End> v<End>
noremap! <S-Right> <C-O>v
noremap! <S-End> <C-O>v<End>
vnoremap <S-Right> <Right>
nnoremap <S-Up> v<Up>
nnoremap <S-PageUp> v<PageUp>
noremap! <S-Up> <Left><C-O>v<Up>
noremap! <S-PageUp> <Left><C-O>v<PageUp>
vnoremap <S-Up> <Up>
nnoremap <S-Down> v<Down>
nnoremap <S-PageDown> v<PageDown>
noremap! <S-Down> <C-O>v<Down>
noremap! <S-PageDown> <C-O>v<PageDown>
vnoremap <S-Down> <Down>
vnoremap < <gv
vnoremap > >gv
" バッファ操作
" noremap <C-L> :list<CR>
noremap <C-Left> :bp<CR>
noremap <C-Right> :bn<CR>
inoremap <C-Left> <C-O>:bp<CR><Esc>
inoremap <C-Right> <C-O>:bn<CR><Esc>

" http://www.atmarkit.co.jp/flinux/rensai/vim11/11b.html
nmap <silent> <F7> :update<CR>:e .<CR>
imap <silent> <F7> <ESC>:update<CR>:e .<CR>
vmap <silent> <F7> <ESC>:update<CR>:e .<CR>
cmap <silent> <F7> <ESC>:update<CR>:e .<CR>
nmap <F8> :bd<CR>
imap <F8> <ESC> :bd<CR>
" nmap <C-w> :bd<CR> (C-w s/v で分割なので使わない)
" imap <C-w> <ESC> :bd<CR>
nmap ,, :bn<CR>
nmap ,m :bp<CR>
" 指定範囲をコピー
" :r! cat #1 | awk 'NR==41,NR==44'
" 各行をコピー
" :r! cat #1 | awk 'NR==41;NR==44'
" [1] の形式の連番をつける
" :7,33! cat -n | sed -e "s/\s*\([0-9]*\)\t\(.*\)/[\1] \2/"
" r! cat -n #3 | gawk NR==1,NR==4 | sed -e "s/\s*\([0-9]*\)\t\(.*\)/[\1] \2/"
nmap ,n :set number!<CR>
nmap ,h :nohl<CR>
nmap ,r :reg<CR>
nmap ,s :wincmd s<CR>
nmap ,v :wincmd v<CR>
nmap ,w :wincmd w<CR>
nmap ,c :wincmd c<CR>
nmap ,j :wincmd j<CR>
nmap ,k :wincmd k<CR>
nmap ,o :wincmd o<CR>
nmap ,q :qa<CR>
nmap ,p :pwd<CR>
nmap ,g :GtagsCursor<CR>
nmap ,l :ls<CR>
" F , t : 文字検索
nmap f <PageDown>
nmap b <PageUp>
" 関数の定義箇所を探す
map <C-g> :Gtags
" ファイル中で定義されている関数一覧表示
map <C-i> :Gtags -f %<CR>
" 関数参照している箇所を一覧表示
map <C-r> :Gtags -r
" 定義箇所-参照箇所を移動
map <C-j> :GtagsCursor<CR>
" [find]
" !C:\GNU\findutils-4.2.20-2-bin\bin\find.exe %:h -name "*.java"
nmap ,f :!C:\GNU\findutils-4.2.20-2-bin\bin\find.exe %:h -name "*.java"
" [explorer]
" !explorer c:\
" !explorer %:h
" !explorer #3:h
nmap ,e :!explorer
" [global]
" !gtags -v 2>&1 | tee -a test.txt