Guest User

Untitled

a guest
Jun 25th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 7.91 KB | None | 0 0
  1. "----------------------------------------------------
  2. " 基本的な設定
  3. "----------------------------------------------------
  4. " viとの互換性をとらない(vimの独自拡張機能を使う為)
  5. set nocompatible
  6. " 改行コードの自動認識
  7. set fileformats=unix,dos,mac
  8. " ビープ音を鳴らさない
  9. set vb t_vb=
  10.  
  11. "----------------------------------------------------
  12. " バックアップ関係
  13. "----------------------------------------------------
  14. " バックアップをとらない
  15. set nobackup
  16. " ファイルの上書きの前にバックアップを作る
  17. " (ただし、backup がオンでない限り、バックアップは上書きに成功した後削除される)
  18. "set writebackup
  19. " バックアップファイルを作るディレクトリ
  20. "set backupdir=$VIM/backup
  21. " スワップファイルを作るディレクトリ
  22. "set directory=$VIM/swap
  23.  
  24. "----------------------------------------------------
  25. " 検索関係
  26. "----------------------------------------------------
  27. " コマンド、検索パターンを100個まで履歴に残す
  28. set history=100
  29. " 検索の時に大文字小文字を区別しない
  30. set ignorecase
  31. " 検索の時に大文字が含まれている場合は区別して検索する
  32. set smartcase
  33. " 最後まで検索したら先頭に戻る
  34. set wrapscan
  35. " インクリメンタルサーチを使う
  36. set incsearch
  37.  
  38. "----------------------------------------------------
  39. " 表示関係
  40. "----------------------------------------------------
  41. " タイトルをウインドウ枠に表示する
  42. set title
  43. " 行番号を表示する
  44. set number
  45. " ルーラーを表示
  46. "set ruler
  47. " タブ文字を CTRL-I で表示し、行末に $ で表示する
  48. set nolist
  49. " 入力中のコマンドをステータスに表示する
  50. set showcmd
  51. " 常にステータス行を表示 (詳細は:he laststatus)
  52. set laststatus=2
  53. " コマンドラインの高さ (Windows用gvim使用時はgvimrcを編集すること)
  54. set cmdheight=2
  55. " 括弧入力時の対応する括弧を表示
  56. set showmatch
  57. " 対応する括弧の表示時間を2にする
  58. set matchtime=2
  59. " シンタックスハイライトを有効にする
  60. syntax on
  61. " 検索結果文字列のハイライトを有効にする
  62. set hlsearch
  63. " コメント文の色を変更
  64. highlight Comment ctermfg=DarkCyan
  65. " 画面を黒地に白にする
  66. colorscheme evening " (Windows用gvim使用時はgvimrcを編集すること)
  67. " コマンドライン補完を拡張モードにする
  68. set wildmenu
  69.  
  70. " 入力されているテキストの最大幅
  71. " (行がそれより長くなると、この幅を超えないように空白の後で改行される)を無効にする
  72. set textwidth=0
  73. " ウィンドウの幅より長い行は折り返して、次の行に続けて表示する
  74. set wrap
  75.  
  76. " 全角スペースの表示
  77. highlight ZenkakuSpace cterm=underline ctermfg=lightblue guibg=darkgray
  78. match ZenkakuSpace / /
  79.  
  80. " ステータスラインに表示する情報の指定
  81. set statusline=%n\:%y%F\ \|%{(&fenc!=''?&fenc:&enc).'\|'.&ff.'\|'}%m%r%=<%l/%L:%p%%>
  82. " ステータスラインの色
  83. highlight StatusLine   term=NONE cterm=NONE ctermfg=black ctermbg=white
  84.  
  85.  
  86. "----------------------------------------------------
  87. " 編集に関する設定:
  88. "----------------------------------------------------
  89. " バックスペースキーで削除できるものを指定
  90. " indent  : 行頭の空白
  91. " eol     : 改行
  92. " start   : 挿入モード開始位置より手前の文字
  93. set backspace=indent,eol,start
  94. " オートインデントを有効にする
  95. set autoindent
  96. " タブが対応する空白の数
  97. set tabstop=4
  98. " タブやバックスペースの使用等の編集操作をするときに、タブが対応する空白の数
  99. set softtabstop=4
  100. " インデントの各段階に使われる空白の数
  101. set shiftwidth=4
  102. " タブを挿入するとき、代わりに空白を使う
  103. set expandtab
  104. " テキスト挿入中の自動折り返しを日本語に対応させる
  105. set formatoptions+=mM
  106.  
  107. "----------------------------------------------------
  108. " 国際化関係
  109. "----------------------------------------------------
  110. " 文字コードの設定
  111. " fileencodingsの設定ではencodingの値を一番最後に記述する
  112. set encoding=utf-8
  113. set termencoding=utf-8
  114. set fileencoding=utf-8
  115. set fileencodings=ucs-bom,euc-jp,cp932,iso-2022-jp
  116. set fileencodings+=,ucs-2le,ucs-2,utf-8
  117. " 文字コードの自動認識
  118. if &encoding !=# 'utf-8'
  119.   set encoding=japan
  120.   set fileencoding=japan
  121. endif
  122. if has('iconv')
  123.   let s:enc_euc = 'euc-jp'
  124.   let s:enc_jis = 'iso-2022-jp'
  125.   " iconvがeucJP-msに対応しているかをチェック
  126.   if iconv("\x87\x64\x87\x6a", 'cp932', 'eucjp-ms') ==# "\xad\xc5\xad\xcb"
  127.     let s:enc_euc = 'eucjp-ms'
  128.     let s:enc_jis = 'iso-2022-jp-3'
  129.   " iconvがJISX0213に対応しているかをチェック
  130.   elseif iconv("\x87\x64\x87\x6a", 'cp932', 'euc-jisx0213') ==# "\xad\xc5\xad\xcb"
  131.     let s:enc_euc = 'euc-jisx0213'
  132.     let s:enc_jis = 'iso-2022-jp-3'
  133.   endif
  134.   " fileencodingsを構築
  135.   if &encoding ==# 'utf-8'
  136.     let s:fileencodings_default = &fileencodings
  137.     let &fileencodings = s:enc_jis .','. s:enc_euc .',cp932'
  138.     let &fileencodings = &fileencodings .','. s:fileencodings_default
  139.     unlet s:fileencodings_default
  140.   else
  141.     let &fileencodings = &fileencodings .','. s:enc_jis
  142.     set fileencodings+=utf-8,ucs-2le,ucs-2
  143.     if &encoding =~# '^\(euc-jp\|euc-jisx0213\|eucjp-ms\)$'
  144.       set fileencodings+=cp932
  145.       set fileencodings-=euc-jp
  146.       set fileencodings-=euc-jisx0213
  147.       set fileencodings-=eucjp-ms
  148.       let &encoding = s:enc_euc
  149.       let &fileencoding = s:enc_euc
  150.     else
  151.       let &fileencodings = &fileencodings .','. s:enc_euc
  152.     endif
  153.   endif
  154.   " 定数を処分
  155.   unlet s:enc_euc
  156.   unlet s:enc_jis
  157. endif
  158. " 日本語を含まない場合は fileencoding に encoding を使うようにする
  159. if has('autocmd')
  160.   function! AU_ReCheck_FENC()
  161.     if &fileencoding =~# 'iso-2022-jp' && search("[^\x01-\x7e]", 'n') == 0
  162.       let &fileencoding=&encoding
  163.     endif
  164.   endfunction
  165.   autocmd BufReadPost * call AU_ReCheck_FENC()
  166. endif
  167. " 改行コードの自動認識
  168. set fileformats=unix,dos,mac
  169. " □とか○の文字があってもカーソル位置がずれないようにする
  170. if exists('&ambiwidth')
  171.   set ambiwidth=double
  172. endif
  173.  
  174. "----------------------------------------------------
  175. " オートコマンド
  176. "----------------------------------------------------
  177. if has("autocmd")
  178.     " ファイルタイプ別インデント、プラグインを有効にする
  179.     filetype plugin indent on
  180.     " カーソル位置を記憶する
  181.     autocmd BufReadPost *
  182.         \ if line("'\"") > 0 && line("'\"") <= line("$") |
  183.         \   exe "normal g`\"" |
  184.         \ endif
  185. endif
  186.  
  187. "----------------------------------------------------
  188. " バイナリモード編集
  189. "----------------------------------------------------
  190. "バイナリ編集(xxd)モード(vim -b での起動、もしくは *.bin ファイルを開くと発動します)
  191. augroup BinaryXXD
  192.   autocmd!
  193.   autocmd BufReadPre  *.bin let &binary =1
  194.   autocmd BufReadPost * if &binary | silent %!xxd -g 1
  195.   autocmd BufReadPost * set ft=xxd | endif
  196.   autocmd BufWritePre * if &binary | %!xxd -r | endif
  197.   autocmd BufWritePost * if &binary | silent %!xxd -g 1
  198.   autocmd BufWritePost * set nomod | endif
  199. augroup END
  200.  
  201. "----------------------------------------------------
  202. " プラグイン
  203. "----------------------------------------------------
  204. " プラグインディレクトリ
  205. let $plugins='$VIM\plugins'
  206. " QuickBuf
  207. source $plugins\qbuf.vim
  208. "ソースをコメントアウト ←→ コメントアウト解除
  209. source $plugins\commentout.vim
  210.  
  211. "----------------------------------------------------
  212. " その他
  213. "----------------------------------------------------
  214. " バッファを切替えてもundoの効力を失わない
  215. set hidden
  216. " 起動時のメッセージを表示しない
  217. set shortmess+=I
Add Comment
Please, Sign In to add comment