nase's watching list
-
[294] Align
-
[1896] allml.vim
-
[1879] autocomplpop.vim
-
[1664] buftabs
-
[52] calendar.vim
-
[625] Color Sampler Pack
-
[2004] ColorSchemeMenuMaker
-
[2150] css_color.vim
-
[1984] fuzzyfinder.vim
-
[197] genutils
-
[311] grep.vim
-
[1581] lookupfile
-
[1242] Markdown syntax
-
[39] matchit.zip
-
[521] mru.vim
-
[69] project.tar.gz
-
[1567] rails.vim
-
[2136] repeat.vim
-
[89] savevers.vim
-
[1601] Smooth Scroll
-
[1318] snippetsEmu
-
[2120] speeddating.vim
-
[1697] surround.vim
-
[1218] The NERD Commenter
-
[1658] The NERD tree
-
[90] vcscommand.vim
-
[1953] Vimpress
-
[670] VisIncr
-
[1234] YankRing.vim
-
[508] ZoomWin
Profile
Windowsでkaoriya版Vimを使ってます。
RubyやRailsも勉強中ですが、まだまだ。
-------------------------
リスト以外で使っているプラグインはこちら
http://www.vector.co.jp/soft/unix/writing/se265654.html
http://d.hatena.ne.jp/secondlife/20070128/1169912371
http://www.kaoriya.net/#CMIGEMO
.vimrc
"+----------------------------------------------------------------------------------------+
" 外観設定
"+----------------------------------------------------------------------------------------+
"カラースキーマを設定
colorscheme zenburn
"ウィンドウを最大化して起動
autocmd GUIEnter * simalt ~x
"入力モード時、ステータスラインのカラーを変更
augroup InsertHook
autocmd!
autocmd InsertEnter * highlight StatusLine guifg=#ccdc90 guibg=#2E4340
autocmd InsertLeave * highlight StatusLine guifg=#2E4340 guibg=#ccdc90
augroup END
"ステータスラインにファイルタイプ・文字コード・改行文字を表示
set statusline=%<[%n]%F%=\ %m%r%h%w%y%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}\ %l,%c\ %P
"全角スペースを視覚化
highlight ZenkakuSpace guifg=#666666
match ZenkakuSpace / /
"末尾の半角スペースを視覚化
highlight WhiteSpaceEOL guibg=#666666
2match WhiteSpaceEOL /\S\@<=\s\+$/
"80桁をハイライト
"hi Highlight80 guibg=#666666
"2match Highlight80 /\%80c/
"NonTextのカラーを設定
highlight NonText guifg=#666666
" ポップアップメニューのカラーを設定
highlight Pmenu guibg=#666666
highlight PmenuSel guibg=#8cd0d3 guifg=#666666
highlight PmenuSbar guibg=#333333
"カーソル行のカラーを設定
highlight CursorLine guibg=#262626
"CursorLineに上書きして行末記号のカラーを設定
highlight EOL guifg=#666666
3match EOL /$/
"+----------------------------------------------------------------------------------------+
" オートコマンド設定
"+----------------------------------------------------------------------------------------+
augroup BufferAu
autocmd!
" カレントディレクトリを自動的に移動
autocmd BufNewFile,BufRead,BufEnter * if isdirectory(expand("%:p:h")) && bufname("%") !~ "NERD_tree" | cd %:p:h | endif
".txtファイルで自動的に日本語入力ON
autocmd BufNewFile,BufRead *.txt setlocal iminsert=2
".rhtmlと.rbと.ymlとhtmlでタブ幅を変更
autocmd BufNewFile,BufRead *.rhtml,*.rb,*.yml,*.html setlocal tabstop=2 shiftwidth=2
"Rails関連ファイルで文字コードをUFT-8に設定
autocmd User Rails* setlocal fileencoding=utf-8
".rbファイルでKでRefe検索
autocmd BufEnter * nnoremap K K
autocmd BufEnter *.rb nnoremap <silent> K :Refe <cword><CR>
"拡張子に応じてファイルタイプを設定
autocmd BufNewFile,BufRead *.mkd setfiletype mkd
"拡張子に応じてビューの自動作成/ロード
autocmd BufWinLeave *_f.txt mkview
autocmd BufNewFile,BufRead,BufEnter *_f.txt silent loadview
".txtのファイルでカーソル行の強調表示を解除
autocmd WinEnter,BufNewFile,BufRead *.txt setlocal nocursorline
augroup END
augroup CommandAu
autocmd!
"grep後に自動的にQuickFixウィンドウを開く
au QuickfixCmdPost grep,vimgrep cw
augroup END
augroup SkeletonAu
autocmd!
autocmd BufNewFile *.html 0r $HOME/vimfiles/templates/skel.html
augroup END
"+----------------------------------------------------------------------------------------+
" 基本設定
"+----------------------------------------------------------------------------------------+
"新しい行のインデントを現在行と同じにする
set autoindent
"バックアップファイルを作るディレクトリ
set backupdir=$HOME/vimbackup
"ファイル保存ダイアログの初期ディレクトリをバッファファイル位置に設定
set browsedir=buffer
"クリップボードをWindowsと連携
set clipboard=unnamed
"Vi互換をオフ
set nocompatible
"スワップファイル用のディレクトリ
set directory=$HOME/vimbackup
"タブの代わりに空白文字を挿入する
set expandtab
"変更中のファイルでも、保存しないで他のファイルを表示
set hidden
"インクリメンタルサーチを行う
set incsearch
"タブ文字、行末など不可視文字を表示する
set list
"listで表示される文字のフォーマットを指定する
set listchars=eol:$,tab:>\ ,extends:<
"行番号を表示する
set number
"閉じ括弧が入力されたとき、対応する括弧を点滅表示しない
set noshowmatch
"検索時に大文字を含んでいたら大/小を区別
set smartcase
"新しい行を作ったときに高度な自動インデントを行う
set smartindent
"行頭の余白内で Tab を打ち込むと、'shiftwidth' の数だけインデントする。
set smarttab
"カーソルを行頭、行末で止まらないようにする
set whichwrap=b,s,h,l,<,>,[,]
"検索をファイルの先頭へループしない
set nowrapscan
"起動時のメッセージを消す
set shortmess+=I
"外部のエディタで編集中のファイルが変更されたら自動的に読み直す
set autoread
"フォントを設定
set guifont=ゆたぽん(コーディング):h12:cSHIFTJIS
"検索結果をハイライトしない
set nohlsearch
"Diff設定 埋め立て行を表示、常に垂直分割
set diffopt=filler,vertical
"コマンドの履歴保存数を指定
set history=100000
"ビューファイルを作るディレクトリ
set viewdir=$HOME/vimfiles/view
"ビューファイルの内容を設定
set viewoptions=folds,cursor
"タブ幅を設定
set tabstop=4 shiftwidth=4
"改行時のコメントアウト自動継続を無効化
set formatoptions-=ro
"標準のGrepツールをAckに
"set grepprg=rak\ -a
"カーソル行の強調表示
set cursorline
"数値のインクリメントは先頭文字にかかわらず10進数で
set nrformats=""
"コマンドラインの高さ
set cmdheight=1
"ツールバーを表示しない
set guioptions-=T
"スクリプト実行中に再描画しない(cursorlineの描画を高速化?)
set lazyredraw
"+----------------------------------------------------------------------------------------+
" Vimスクリプト設定
"+----------------------------------------------------------------------------------------+
"ディレクトリツリーの幅を設定(NERD_tree.vim)
let g:NERDTreeWinSize = 24
"F1~4でディレクトリツリーを表示
noremap <F1> :NERDTreeToggle<CR>
noremap <F2> :NERDTree $VIM_NT_HOME<CR>
noremap <F3> :NERDTree C:/<CR>
noremap <F4> :NERDTree D:/<CR>
"ファイル履歴の保存先を設定(mru.vim)
let MRU_File = $HOME . '\_vim_mru_files'
"ファイル履歴の保存件数を設定
let MRU_Max_Entries = 30
"F9でファイル履歴を表示
noremap <F9> :MRU<CR>
"GUIメニューを表示しない(動作せず?)
"let MRU_Add_Menu = 0
"Rails.vimの設定(rails.vim)
let g:rails_level = 4
let g:rails_devalut_database = 'mysql'
"<Leader>yrでヤンクリングを表示(yankring.vim)
nmap <Leader>yr :YRShow<CR>
"viminfoの設定に!を追加してヤンク履歴をviminfoに保存(set nocompatibleより後ろに書くこと)
set viminfo^=!
"F11でウィンドウトグル(ZoomWin.vim)
nmap <unique> <F11> <Plug>ZoomWin
"出力するHTMLをXHTMLに強制(tohtml.vim)
let g:use_xhtml = 1
"HTMLを出力する際に行番号を出力
let g:html_number_lines = 0
"コードのシンタックスを<font>ではなく<span>で出力
let g:html_use_css = 1
"ソースコードがfoldingされていても内部をHTML出力する
let g:html_ignore_folding = 1
"FuzzyFinderの個別機能を有効/無効化(fuzzyfinder.vim)
let g:FuzzyFinderOptions.Buffer.mode_available = 0
let g:FuzzyFinderOptions.File.mode_available = 1
let g:FuzzyFinderOptions.MruFile.mode_available = 1
let g:FuzzyFinderOptions.MruCmd.mode_available = 0
let g:FuzzyFinderOptions.FavFile.mode_available = 0
let g:FuzzyFinderOptions.Dir.mode_available = 0
let g:FuzzyFinderOptions.Tag.mode_available = 0
let g:FuzzyFinderOptions.TaggedFile.mode_available = 0
"FuzzyFinderでmigemoを利用
let g:FuzzyFinderOptions.Base.migemo_support = 1
"<F12>でFuzzyFinderFileを表示
noremap <F12> :FuzzyFinderFile<CR>
"<F9>でFuzzyFinderMruFileを表示
"noremap <F9> :FuzzyFinderMruFile<CR>
"<Leader>xでコメントをトグル(NERD_commenter.vim)
map <Leader>x ,c<space>
"未対応ファイルタイプのエラーメッセージを表示しない
let NERDShutUp=1
"Rubyのオムニ補完を設定(ft-ruby-omni)
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
"カレンダー用に日記ディレクトリを指定(calendar.vim)
let g:calendar_diary = $HOME . '\my_memo\diary'
"<M-UP>でタブバーをトグル(tabbar.vim)
"noremap <M-UP> :TbToggle<CR>
"let g:Tb_MaxSize=1
"hi Tb_Normal guibg=#3f3f3f guifg=#999999 gui=italic
"hi Tb_Changed guibg=#3f3f3f guifg=#cc9393 gui=italic
"hi Tb_VisibleNormal guibg=#2E3330 guifg=#88b090
"hi Tb_VisibleChanged guibg=#2E3330 guifg=#cc9393
"let g:Tb_ModSelTarget=1
"<Leader>cvでタブバーを消し、VCSVimDiffを表示(vcscommand.vim)
nmap <Leader>cv :VCSVimDiff<CR>
"g?をMigemoによる拡張検索にマップ(migemo.vim)
set migemo
"savevers.vimを動作させるためパッチモードへ移行(savevers.vim)
set patchmode=.clean
"バージョン管理ファイルを保存するディレクトリ
let savevers_dirs = &backupdir
"パッチモードでバージョン管理する最大数
let savevers_max = 3
":Purgeでカレントファイルの全てのバックアップを削除
let savevers_purge = 0
"Diff表示の際にウィンドウをリサイズしない
let versdiff_no_resize = 1
"<F5>でひとつ前のバックアップと比較
noremap <silent> <F5> :VersDiff -<CR>
"<F6>でひとつ後のバックアップと比較
noremap <silent> <F6> :VersDiff +<CR>
"<Leader>vqでVersDiffから抜ける
noremap <silent> <Leader>vq :VersDiff -c<CR>
"外部grep設定(grep.vim)
"let Grep_Path = 'C:\GnuWin32\bin\grep.exe'
let Grep_Path = 'D:\UnxUtils\usr\local\wbin\grep.exe'
let Agrep_Path = 'C:\GnuWin32\bin\agrep.exe'
let Fgrep_Path = 'C:\GnuWin32\bin\grep.exe -F'
"let Egrep_Path = 'C:\GnuWin32\bin\grep.exe -E'
let Egrep_Path = 'D:\UnxUtils\usr\local\wbin\grep.exe -E'
let Grep_Find_Path = 'C:\GnuWin32\bin\find.exe'
let Grep_Xargs_Path = 'C:\GnuWin32\bin\xargs.exe'
let Grep_Default_Options = '-i'
let Grep_Skip_Dirs = '.svn'
let Grep_Skip_Files = '*.bak *~'
let Grep_Shell_Quote_Char = '"'
"↓for Unix/Linux
"let Grep_Shell_Quote_Char = "'"
"<PageDown>と<PageUp>もスムーズスクロール(smooth_scroll.vim)
nnoremap <PageDown> <C-F>
nnoremap <PageUp> <C-B>
"<Leader>riでlookupfile.vimを使ってRefe検索(refe.vim)
"nmap <silent> <Leader>ri :Refe<CR>
"検索にlookupfile.vimを使用しない
let g:loaded_lookupfile = 0
let g:RefeUseLookupFile = 0
"補完候補を自動的にポップアップ(autocomplpop.vim)
"大文字小文字を区別しない
let g:AutoComplPop_IgnoreCaseOption = 1
"<TAB>で補完
" {{{ Autocompletion using the TAB key
" This function determines, wether we are on the start of the line text (then tab indents) or
" if we want to try autocompletion
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
"return "\<TAB>"
return ""
else
if pumvisible()
return "\<C-N>"
else
return "\<C-N>\<C-P>"
end
endif
endfunction
" Remap the tab key to select action with InsertTabWrapper
inoremap <S-CR> <c-r>=InsertTabWrapper()<cr>
" }}} Autocompletion using the TAB key
"途中でEnterしたとき、ポップアップを消して改行
inoremap <expr> <CR> pumvisible() ? "\<C-Y>\<CR>" : "\<CR>"
"<Leader>lで選択範囲をリスト化(visincr.vim)
vnoremap <silent> <Leader>l :s/^/1\./<CR>gv^o^<C-v>:I<CR>j
"バッファタブにファイル名のみ表示(buftabs.vim)
let g:buftabs_only_basename=1
"バッファタブをステータスライン内に表示
let g:buftabs_in_statusline=1
"+----------------------------------------------------------------------------------------+
" キーマップ設定
"+----------------------------------------------------------------------------------------+
"Ctrl+Delで検索ハイライトをクリア
nnoremap <C-Del> :nohlsearch<CR>
"検索語が画面の真ん中に来るようにする
nnoremap n nzz
nnoremap N Nzz
"nmap * *zz
"nmap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
"*で部分一致も検索する
nnoremap * g*zz
nnoremap # g#zz
"行末まで移動したとき表示行が真ん中にくるようにする
nnoremap G Gzz
"改行する
noremap \<CR> o<ESC>
"コマンドモード時のカーソル移動
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
cnoremap <C-f> <Right>
cnoremap <C-b> <Left>
" 挿入モード時のカーソル移動
inoremap <C-a> <Home>
inoremap <C-e> <End>
inoremap <C-f> <Right>
inoremap <C-b> <Left>
"表示行単位で行移動
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
"<C-kPlus>と<C-kMinus>でフレームサイズを変更
noremap <C-kPlus> <C-W>+
noremap <C-kMinus> <C-W>-
"<Leader>dqでDiffから抜ける
nnoremap <Leader>dq :winc l<CR>:bw<CR>:diffoff<CR>
"F7とF8で前後の変更箇所へ移動
nnoremap <F7> [c
nnoremap <F8> ]c
"F8で日付を挿入
"noremap <F8> i<CR><CR><ESC>k!!date /T<CR>$xkgJgJ
"inoremap <F8> <CR><CR><ESC>k!!date /T<CR>$xkgJgJi
"<C-Space>でomni補完
inoremap <C-Space> <C-x><C-o>
"<Leader>qで保存せずにバッファを閉じる
noremap <Leader>q :bw!<CR>
"「,v」でgvimrcを開く
nnoremap ,v :e $HOME/_gvimrc<CR>
"「,m」でvim_memo.txtを開く
nnoremap ,m :e $HOME/my_memo/vim_memo.txt<CR>
"「,a」でMyAutoHotKey.ahkを開く
nnoremap ,a :e $HOME/my_ahk/MyAutoHotKey_kinesis.ahk<CR>
"ALT+左右矢印キーでバッファを移動
noremap <M-RIGHT> :bn<CR>
noremap <M-LEFT> :bp<CR>
"ALT+下矢印キーで現在のバッファを閉じる
noremap <M-DOWN> :bd<CR>i<ESC>
"行末尾からブロック開始
inoremap <M-}> <ESC>A<SPACE>{}<Left><CR><ESC>O<TAB>
nnoremap <M-}> A<SPACE>{}<Left><CR><ESC>O<TAB>
"括弧を入力
inoremap <M-)> ()<LEFT>
inoremap <M-]> []<LEFT>
"<Leader><Leader>で変更があれば保存
noremap <Leader><Leader> :up<CR>
"コマンドラインで履歴を検索
cnoremap <C-P> <UP>
cnoremap <C-N> <DOWN>
"QuickFixリストで項目移動
nnoremap <C-Down> :cn<CR>zz
nnoremap <C-Up> :cp<CR>zz
"行連結
nnoremap J gJ
nnoremap <Space> jzz
nnoremap <S-Space> kzz
"folding を h,l で閉じたり開いたりするマッピング - (’q’) log
"http://d.hatena.ne.jp/ns9tks/20080318/1205851539
"行頭で h を押すと折畳を閉じる。
nnoremap <expr> h col('.') == 1 && foldlevel(line('.')) > 0 ? 'zc' : 'h'
"折畳上で l を押すと折畳を開く。
nnoremap <expr> l foldclosed(line('.')) != -1 ? 'zo0' : 'l'
"行頭で h を押すと選択範囲に含まれる折畳を閉じる。
vnoremap <expr> h col('.') == 1 && foldlevel(line('.')) > 0 ? 'zcgv' : 'h'
"折畳上で l を押すと選択範囲に含まれる折畳を開く。
vnoremap <expr> l foldclosed(line('.')) != -1 ? 'zogv0' : 'l'
"<C-h>でヘルプの検索準備
nnoremap <C-h> :<C-u>help<Space>
"xmpfilter用設定
" <S-F1>で現在行/選択行にxmpfilterを実行
map <silent> <S-F1> !xmpfilter -a<cr>
nmap <silent> <S-F1> V<S-F1>
imap <silent> <S-F1> <ESC><S-F1>a
" Test::Unit assertions; use -s to generate RSpec expectations instead
"map <silent> <S-F10> !xmpfilter -u<cr>
"nmap <silent> <S-F10> V<S-F10>
"imap <silent> <S-F10> <ESC><S-F10>a
" <S-F2>でバッファ全体にxmpfilterを実行
nmap <silent> <S-F2> mzggVG!xmpfilter -a<cr>'z
imap <silent> <S-F2> <ESC><S-F2>
" assertions
"nmap <silent> <S-F11> mzggVG!xmpfilter -u<cr>'z
"imap <silent> <S-F11> <ESC><S-F11>a
" <S-F3>で現在行/選択行に「# =>」マークを追加
vmap <silent> <S-F3> !xmpfilter -m<cr>
nmap <silent> <S-F3> V<S-F3>
imap <silent> <S-F3> <ESC><S-F3>a
" <S-F4>で現在行/選択行の「# =>」マークを削除
vmap <silent> <S-F4> ms:call RemoveRubyEval()<CR>
nmap <silent> <S-F4> V<S-F4>
imap <silent> <S-F4> <ESC><S-F4>a
function! RemoveRubyEval() range
let begv = a:firstline
let endv = a:lastline
normal Hmt
set lz
execute ":" . begv . "," . endv . 's/\s*# \(=>\|!!\).*$//e'
normal 'tzt`s
set nolz
redraw
endfunction
"+----------------------------------------------------------------------------------------+
" 追加コマンド
"+----------------------------------------------------------------------------------------+
"<leader>wでURLを開く
let $PATH = $PATH . ';C:\Program Files\Mozilla Firefox'
"=== evoke a web browser
function! Browser()
let line0 = getline(".")
let line = matchstr(line0, "http[^ ]*")
:if line==""
let line = matchstr(line0, "ftp[^ ]*")
:endif
:if line==""
let line = matchstr(line0, "file[^ ]*")
:endif
"let line = escape(line, "#?&;|%")
":if line==""
" let line = "\"" . (expand("%:p")) . "\""
":endif
exec ':silent !firefox.exe ' . "\"" . line . "\""
endfunction
noremap <Leader>w :call Browser()<CR>
" Save the current buffer and execute the Tortoise SVN interface's diff program
noremap <unique> <silent> <leader>td :w<CR>:silent !"C:\Progra~1\TortoiseSVN\bin\TortoiseProc.exe /command:diff /path:"%" /notempfile /closeonend"<CR>
" Save the current buffer and execute the Tortoise SVN interface's log
noremap <unique> <silent> <leader>tl :w<CR>:silent !"C:\Progra~1\TortoiseSVN\bin\TortoiseProc.exe /command:log /path:"%" /notempfile /closeonend"<CR>
" Save the current buffer and execute the Tortoise SVN interface's revision graph
noremap <unique> <silent> <leader>tr :w<CR>:silent !"C:\Progra~1\TortoiseSVN\bin\TortoiseProc.exe /command:revisiongraph epath:"%" /notempfile /closeonend"<CR>
" Save the current buffer and execute the Tortoise SVN interface's blame program
noremap <unique> <leader>tb :call TortoiseBlame()<CR>
fu! TortoiseBlame()
" Save the buffer
silent execute(':w')
" Now run Tortoise to get the blame dialog to display
let filename = expand("%")
let linenum = line(".")
silent execute('!C:\Progra~1\TortoiseSVN\bin\TortoiseProc.exe /command:blame /path:"' . filename . '" /line:' . linenum . ' /notempfile /closeonend')
endfunc
"preview interpreter's output(Tip #1244)
function! Ruby_eval_vsplit() range
if &filetype == "ruby"
let src = tempname()
let dst = "Ruby Output"
" put current buffer's content in a temp file
silent execute ": " . a:firstline . "," . a:lastline . "w " . src
" open the preview window
silent execute ":pedit! " . dst
" change to preview window
wincmd P
" set options
setlocal buftype=nofile
setlocal noswapfile
setlocal syntax=none
setlocal bufhidden=delete
" replace current buffer with ruby's output
silent execute ":%! ruby " . src . " 2>&1 "
" change back to the source buffer
wincmd p
endif
endfunction
"<F10>でバッファのRubyスクリプトを実行し、結果をプレビュー表示
vmap <silent> <F10> :call Ruby_eval_vsplit()<CR>
nmap <silent> <F10> mzggVG<F10>`z
nmap <silent> <S-F10> :pc<CR>
"<M-F10>でRubyスクリプトを保存後シンタックスチェックし、エラーをQuickFixに表示
nnoremap <silent> <M-F10> :w<CR>:make -c %<CR>:cw<CR>:cfirst<CR>zz
nnoremap <silent> <M-S-F10> :ccl<CR>
"<C-F10>でRubyスクリプトを保存後コマンドプロンプトから実行
nnoremap <silent> <C-F10> :w<CR>:!ruby %<CR>
"他のバッファを全て閉じる
function! DeleteOtherBuffers()
let bufs=range(0,bufnr('$'))
let curbufnr = bufnr('%')
call remove(bufs,curbufnr)
for i in bufs
execute "silent! bdelete ".i
endfor
endfunction
nnoremap <silent> <M-Up> :call DeleteOtherBuffers()<CR>i<ESC>
"<Leader>esでHTML のスペシャルキャラクタをエスケープする
"http://bitmap.dyndns.org/blog/archives/001546.html
function! EscapeHTMLSpecialChars() range
let n = a:firstline
while n <= a:lastline
let target = getline(n)
let target = substitute(target, "\&", "\\&", "g")
let target = substitute(target, "<", "\\<", "g")
let target = substitute(target, ">", "\\>", "g")
call setline(n, target)
let n = n + 1
endwhile
endfunction
noremap <silent> <Leader>es :call EscapeHTMLSpecialChars()<CR>
"+----------------------------------------------------------------------------------------+
" 文字コードの自動認識(by:ずんWiki)
"+----------------------------------------------------------------------------------------+
"文字コードの自動認識
if &encoding !=# 'utf-8'
set encoding=japan
set fileencoding=japan
endif
if has('iconv')
let s:enc_euc = 'euc-jp'
let s:enc_jis = 'iso-2022-jp'
" iconvがeucJP-msに対応しているかをチェック
if iconv("\x87\x64\x87\x6a", 'cp932', 'eucjp-ms') ==# "\xad\xc5\xad\xcb"
let s:enc_euc = 'eucjp-ms'
let s:enc_jis = 'iso-2022-jp-3'
" iconvがJISX0213に対応しているかをチェック
elseif iconv("\x87\x64\x87\x6a", 'cp932', 'euc-jisx0213') ==# "\xad\xc5\xad\xcb"
let s:enc_euc = 'euc-jisx0213'
let s:enc_jis = 'iso-2022-jp-3'
endif
" fileencodingsを構築
if &encoding ==# 'utf-8'
let s:fileencodings_default = &fileencodings
let &fileencodings = s:enc_jis .','. s:enc_euc .',cp932'
let &fileencodings = &fileencodings .','. s:fileencodings_default
unlet s:fileencodings_default
else
let &fileencodings = &fileencodings .','. s:enc_jis
set fileencodings+=utf-8,ucs-2le,ucs-2
if &encoding =~# '^\(euc-jp\|euc-jisx0213\|eucjp-ms\)$'
set fileencodings+=cp932
set fileencodings-=euc-jp
set fileencodings-=euc-jisx0213
set fileencodings-=eucjp-ms
let &encoding = s:enc_euc
let &fileencoding = s:enc_euc
else
let &fileencodings = &fileencodings .','. s:enc_euc
endif
endif
" 定数を処分
unlet s:enc_euc
unlet s:enc_jis
endif
" 日本語を含まない場合は fileencoding に encoding を使うようにする
if has('autocmd')
function! AU_ReCheck_FENC()
if &fileencoding =~# 'iso-2022-jp' && search("[^\x01-\x7e]", 'n') == 0
let &fileencoding=&encoding
endif
endfunction
autocmd BufReadPost * call AU_ReCheck_FENC()
endif
" 改行コードの自動認識
set fileformats=dos,unix,mac
" □とか○の文字があってもカーソル位置がずれないようにする
if exists('&ambiwidth')
set ambiwidth=double
endif
set printoptions=number:y,syntax:n,left:2pc,right:4pc,top:3pc,bottom:3pc
set printfont=Osaka-等幅:h10:cSHIFTJIS
"+----------------------------------------------------------------------------------------+
" Linux環境向け
"+----------------------------------------------------------------------------------------+
"vim で編集中のファイル名を screen のタイトルに表示する(「^[」は<Ctrl-v>Escで入力)
"autocmd BufEnter * if bufname("") !~ "^\[A-Za-z0-9\]*://" | silent! exe '!echo -n "^[k%^[\\"' | endif
