Skip to content

Instantly share code, notes, and snippets.

@mdaisuke
Created April 3, 2011 13:13
Show Gist options
  • Save mdaisuke/900420 to your computer and use it in GitHub Desktop.
Save mdaisuke/900420 to your computer and use it in GitHub Desktop.
"" plugins
call pathogen#runtime_append_all_bundles()
"let g:neocomplcache_enable_at_startup = 1
"" settings
filetype plugin indent on
syntax enable
set backspace=eol,indent,start
set ignorecase
set smartcase
set hlsearch
"set incsearch
set showmode
set laststatus=2
set statusline=%<%F\ %r%h%w%y%{'['.(&fenc!=''?&fenc:&enc).'\|'.&ff.']'}\ \ %l/%L\ (%P)%m%=%{strftime(\"%Y/%m/%d\ %H:%M\")}
set tabstop=2
set shiftwidth=2
set expandtab
set autoindent
set nocompatible
set nu
set hidden
set wildmenu
set wildmode=list:longest,full
set splitbelow
set splitright
set background=dark
set cursorline
"" hokan
inoremap { {}<LEFT>
inoremap [ []<LEFT>
inoremap ( ()<LEFT>
inoremap ' ''<LEFT>
inoremap " ""<LEFT>
"" mappings
autocmd WinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
autocmd ColorScheme *
\ highlight TabLine
\ cterm=NONE
\ ctermfg=lightgray
\ ctermbg=darkgray
doautocmd ColorScheme _
nnoremap <Space>. :<C-u>edit $MYVIMRC<Enter>
nnoremap <Space>s. :<C-u>source $MYVIMRC<Enter>
nnoremap <Space>, :<C-u>NERDTree<Enter>
nnoremap <C-l> $
nnoremap <C-h> 0
"nnoremap <C-h> ^
inoremap <C-j> <Esc>
"nnoremap <C-h> :<C-u>help<Space>
"nnoremap <C-h><C-h> :<C-u>help<Space><C-r><C-w><Enter>
"nnoremap <Space>w <C-w>
"noremap ; :
"noremap : ;
"noremap j gj
"noremap k gk
"noremap gj j
"noremap gk k
"nnoremap <C-t> <Nop>
"nnoremap <C-t>n :<C-u>tabnew<CR>
"nnoremap <C-t>c :<C-u>tabclose<CR>
"nnoremap <C-t>o :<C-u>tabonly<CR>
"nnoremap <C-t>j :<C-u>execute 'tabnext' 1 + (tabpagenr() + v:count1 -1) % tabpagenr('$')<CR>
"nnoremap <C-t>k gT
"nnoremap t <Nop>
"nnoremap tt <C-]>
"nnoremap tj :<C-u>tag<CR>
"nnoremap tk :<C-u>pop<CR>
"nnoremap tl :<C-u>tags<CR>
"inoremap <expr> ,df strftime('%Y-%m-%dT%H:%M:%S')
"inoremap <expr> ,dd strftime('%Y-%m-%d')
"inoremap <expr> ,dt strftime('%H:%M:%S')
"nnoremap gc `[v`]
"vnoremap gc :<C-u>normal gc<Enter>
"onoremap gc :<C-u>normal gc<Enter>
"cnoremap <expr> /
" \ getcmdtype() == '/' ? '\/' : '/'
"cnoremap <expr> ?
" \ getcmdtype() == '?' ? '\?' : '?'
"nnoremap <Space>j <C-f>
"nnoremap <Space>k <C-b>
"nnoremap c. q:k<Cr>
command! Cp932 edit ++enc=cp932
command! Eucjp edit ++enc=euc-jp
command! Iso2022jp edit ++enc=iso-2022-jp
command! -bang -bar -complete=file -nargs=? Utf8
\ edit<bang> ++enc=utf-8 <args>
command! Jis Iso2022jp
command! Sjis Cp932
command! -complete=customlist,CompleteCD -nargs=? CD cd <args>
function! CompleteCD(arglead, cmdline, cursorpos)
let pattern = join(split(a:cmdline, '\s', !0)[1:], ' ') . '*/'
return split(globpath(&cdpath, pattern), "\n")
endfunction
command! Big wincmd _ | wincmd |
"" 文字コードの自動認識
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=unix,dos,mac
" □とか○の文字があってもカーソル位置がずれないようにする
if exists('&ambiwidth')
set ambiwidth=double
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment