Skip to content

Instantly share code, notes, and snippets.

@monzou
Created October 30, 2011 13:24
Show Gist options
  • Save monzou/1325892 to your computer and use it in GitHub Desktop.
Save monzou/1325892 to your computer and use it in GitHub Desktop.
dotfiles
" プラグインのロード
filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
set helpfile=$VIMRUNTIME/doc/help.txt
filetype plugin on
" 行番号を表示
set number
" カレントウインドウのカーソル行をハイライト
set cursorline
augroup cch
autocmd! cch
autocmd WinLeave * set nocursorline
autocmd WinEnter, BufRead * set cursorline
augroup END
:hi clear Cursorline
:hi Cursorline gui=underline
highlight Cursorline ctermbg=darkgray guibg=darkgray
" ESC * 2 で検索キーワードのハイライトを消せるように
nmap <ESC><ESC> :nohlsearch<CR><ESC>
" バッファ保存時に行末の空白除去
" autocmd BufWritePre * :%s/\s\+$//ge
" autocmd BufWritePre * :%s/\t/ /ge
" 挿入モードでも CTRL + hjkl で移動可能にする
inoremap <C-e> <End>
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
" 括弧の中のカーソルを元に戻す
inoremap { {}<LEFT>
inoremap [ []<LEFT>
inoremap ( ()<LEFT>
inoremap " ""<LEFT>
inoremap ' ''<LEFT>
vnoremap { "zdi^V{<C-R>z}<ESC>
vnoremap [ "zdi^V[<C-R>z]<ESC>
vnoremap ( "zdi^V(<C-R>z)<ESC>
vnoremap " "zdi^V"<C-R>z^V"<ESC>
vnoremap ' "zdi'<C-R>z'<ESC>
set tabstop=4
set shiftwidth=2
set nocompatible
syntax on
filetype indent on
" 文字コードの自動認識
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
"utf-8優先にする
if &encoding == 'utf-8'
let &fileencodings = substitute(&fileencodings, 'utf-8', '_utf-8', 'g')
let &fileencodings = substitute(&fileencodings, 'cp932', 'utf-8', 'g')
let &fileencodings = substitute(&fileencodings, '_utf-8', 'cp932', 'g')
endif
" 改行コードの自動認識
"set fileformats=dos,unix,mac
" □とか○の文字があってもカーソル位置がずれないようにする
if exists('&ambiwidth')
set ambiwidth=double
endif
if exists("loaded_ReCheckFENC")
finish
endif
let loaded_ReCheckFENC = 1
" 日本語を含まない場合は 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
" Qfixhowm の設定
set runtimepath+=/Users/monzou/Dropbox/dev/qfixapp
let QFixHowm_Key = 'g'
let howm_dir = '/Users/monzou/Dropbox/PlainText/howm/source'
let howm_filename = '%Y/%m/%Y-%m-%d-%H-%M%S.txt'
let howm_fileencoding = 'utf-8'
let howm_fileformat = 'unix'
let QFixHowm_DiaryFile = 'Diary/%Y/%m/%Y-%m-%d.txt'
let QFixHowm_OpenURIcmd = "open 'Applications/Google Chrome.app' %s"
" Howm2html の設定
let HowmHtml_htmldir = '/Users/monzou/Dropbox/PlainText/howm/html'
let HowmHtml_basedir = howm_dir
let HowmHtml_Vicuna = 'single'
let HowmHtml_SightName = 'howm'
" Clipboard コピー
set clipboard+=unnamed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment