Created
May 13, 2009 09:02
-
-
Save Shougo/110942 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"--------------------------------------------------------------------------- | |
" Shougo's .vimrc | |
"--------------------------------------------------------------------------- | |
" Initialize:"{{{ | |
" | |
if has('win32') || has('win64') | |
" For Windows. | |
language en | |
else | |
" For Linux. | |
language mes C | |
endif | |
" \の代わりに'm'を使えるようにする | |
" ','より押しやすい。 | |
" プラグイン用設定の前に設定しないとうまくマッピングされない。 | |
let mapleader = 'm' | |
" グローバルプラグインでは <Leader> を使用 | |
let g:mapleader = 'm' | |
" ファイルタイププラグインでは <LocalLeader> を使用 | |
" 'm'の隣だから','を使用する。 | |
let g:maplocalleader = ',' | |
" plug-inのためにキーマップを解放する | |
nnoremap ; <Nop> | |
xnoremap ; <Nop> | |
nnoremap m <Nop> | |
xnoremap m <Nop> | |
nnoremap , <Nop> | |
xnoremap , <Nop> | |
" Windows/Linuxにおいて、.vimと$VIM/vimfilesの違いを吸収する | |
if has('win32') || has('win64') | |
let $DOTVIM = $VIM."/vimfiles" | |
else | |
let $DOTVIM = $HOME."/.vim" | |
endif | |
" コンソールでは$MYGVIMRCに値がセットされていないのでセットする | |
if !exists($MYGVIMRC) | |
if has('win32') || has('win64') | |
let $MYGVIMRC = $VIM."/.gvimrc" | |
else | |
let $MYGVIMRC = $HOME."/.gvimrc" | |
endif | |
endif | |
" Anywhere SID. | |
function! s:SID_PREFIX() | |
return matchstr(expand('<sfile>'), '<SNR>\d\+_') | |
endfunction | |
" 最初に処理して、設定を上書きする | |
filetype plugin on | |
filetype indent on | |
" Set augroup. | |
augroup MyAutoCmd | |
autocmd! | |
augroup END | |
"}}} | |
"--------------------------------------------------------------------------- | |
" Encoding:"{{{ | |
" | |
" The automatic recognition of the character code. | |
" Setting of the encoding to use for a save and reading. | |
" Make it normal in UTF-8 in Unix. | |
set encoding=utf-8 | |
" Setting of terminal encoding."{{{ | |
if !has('gui_running') | |
if &term == 'win32' || &term == 'win64' | |
" Setting when use the non-GUI Japanese console. | |
" Garbled unless set this. | |
set termencoding=cp932 | |
" Japanese input changes itself unless set this. | |
" Be careful because the automatic recognition of the character code is not possible! | |
set encoding=japan | |
else | |
if $ENV_ACCESS ==# 'cygwin' | |
set termencoding=cp932 | |
elseif $ENV_ACCESS ==# 'linux' | |
set termencoding=euc-jp | |
elseif $ENV_ACCESS ==# 'colinux' | |
set termencoding=utf-8 | |
else " fallback | |
set termencoding= " same as 'encoding' | |
endif | |
endif | |
endif | |
"}}} | |
" The automatic recognition of the character code."{{{ | |
if !exists('did_encoding_settings') && has('iconv') | |
let s:enc_euc = 'euc-jp' | |
let s:enc_jis = 'iso-2022-jp' | |
" Does iconv support JIS X 0213? | |
if iconv("\x87\x64\x87\x6a", 'cp932', 'euc-jisx0213') ==# "\xad\xc5\xad\xcb" | |
let s:enc_euc = 'euc-jisx0213,euc-jp' | |
let s:enc_jis = 'iso-2022-jp-3' | |
endif | |
" Build encodings. | |
let &fileencodings = 'ucs-bom' | |
if &encoding !=# 'utf-8' | |
let &fileencodings = &fileencodings . ',' . 'ucs-2le' | |
let &fileencodings = &fileencodings . ',' . 'ucs-2' | |
endif | |
let &fileencodings = &fileencodings . ',' . s:enc_jis | |
if &encoding ==# 'utf-8' | |
let &fileencodings = &fileencodings . ',' . s:enc_euc | |
let &fileencodings = &fileencodings . ',' . 'cp932' | |
elseif &encoding =~# '^euc-\%(jp\|jisx0213\)$' | |
let &encoding = s:enc_euc | |
let &fileencodings = &fileencodings . ',' . 'utf-8' | |
let &fileencodings = &fileencodings . ',' . 'cp932' | |
else " cp932 | |
let &fileencodings = &fileencodings . ',' . 'utf-8' | |
let &fileencodings = &fileencodings . ',' . s:enc_euc | |
endif | |
let &fileencodings = &fileencodings . ',' . &encoding | |
unlet s:enc_euc | |
unlet s:enc_jis | |
let did_encoding_settings = 1 | |
endif | |
"}}} | |
" When do not include Japanese, use encoding for fileencoding. | |
function! AU_ReCheck_FENC() | |
if &fileencoding =~# 'iso-2022-jp' && search("[^\x01-\x7e]", 'n') == 0 | |
let &fileencoding=&encoding | |
endif | |
endfunction | |
autocmd MyAutoCmd BufReadPost * call AU_ReCheck_FENC() | |
" Default fileformat. | |
set fileformat=unix | |
" Automatic recognition of a new line cord. | |
set fileformats=unix,dos,mac | |
" A fullwidth character is displayed in vim properly. | |
set ambiwidth=double | |
" Command group opening with a specific character code again."{{{ | |
" In particular effective when I am garbled in a terminal. | |
" Open in UTF-8 again. | |
command! -bang -bar -complete=file -nargs=? Utf8 edit<bang> ++enc=utf-8 <args> | |
" Open in iso-2022-jp again. | |
command! -bang -bar -complete=file -nargs=? Iso2022jp edit<bang> ++enc=iso-2022-jp <args> | |
" Open in Shift_JIS again. | |
command! -bang -bar -complete=file -nargs=? Cp932 edit<bang> ++enc=cp932 <args> | |
" Open in EUC-jp again. | |
command! -bang -bar -complete=file -nargs=? Euc edit<bang> ++enc=euc-jp <args> | |
" Open in UTF-16 again. | |
command! -bang -bar -complete=file -nargs=? Utf16 edit<bang> ++enc=ucs-2le <args> | |
" Open in UTF-16BE again. | |
command! -bang -bar -complete=file -nargs=? Utf16be edit<bang> ++enc=ucs-2 <args> | |
" Aliases. | |
command! -bang -bar -complete=file -nargs=? Jis Iso2022jp<bang> <args> | |
command! -bang -bar -complete=file -nargs=? Sjis Cp932<bang> <args> | |
command! -bang -bar -complete=file -nargs=? Unicode Utf16<bang> <args> | |
"}}} | |
" Tried to make a file note version."{{{ | |
" Don't save it because dangerous. | |
command! WUtf8 setlocal fenc=utf-8 | |
command! WIso2022jp setlocal fenc=iso-2022-jp | |
command! WCp932 setlocal fenc=cp932 | |
command! WEuc setlocal fenc=euc-jp | |
command! WUtf16 setlocal fenc=ucs-2le | |
command! WUtf16be setlocal fenc=ucs-2 | |
" Aliases. | |
command! WJis WIso2022jp | |
command! WSjis WCp932 | |
command! WUnicode WUtf16 | |
"}}} | |
" Handle it in nkf and open. | |
command! Nkf !nkf -g % | |
" Appoint a line feed."{{{ | |
command! -bang -bar -complete=file -nargs=? Unix edit<bang> ++fileformat=unix <args> | |
command! -bang -bar -complete=file -nargs=? Mac edit<bang> ++fileformat=mac <args> | |
command! -bang -bar -complete=file -nargs=? Dos edit<bang> ++fileformat=dos <args> | |
command! -bang -complete=file -nargs=? WUnix write<bang> ++fileformat=unix <args> | edit <args> | |
command! -bang -complete=file -nargs=? WMac write<bang> ++fileformat=mac <args> | edit <args> | |
command! -bang -complete=file -nargs=? WDos write<bang> ++fileformat=dos <args> | edit <args> | |
"}}}"}}} | |
" ku.vim"{{{ | |
" The prefix key. | |
nnoremap [Ku] <Nop> | |
nmap ' [Ku] | |
nnoremap [Ku]u :<C-u>Ku<Space> | |
nnoremap <silent> [Ku]a :<C-u>Ku args<CR> | |
nnoremap <silent> [Ku]b :<C-u>Ku buffer<CR> | |
nnoremap <silent> [Ku]c :<C-u>Ku cmd_mru<CR> | |
nnoremap <silent> [Ku]f :<C-u>Ku file<CR> | |
nnoremap <silent> [Ku]g :<C-u>Ku metarw-git<CR> | |
nnoremap <silent> [Ku]h :<C-u>Ku history<CR> | |
nnoremap <silent> [Ku]k :<C-u>call ku#restart()<CR> | |
nnoremap <silent> [Ku]m :<C-u>Ku file_mru<CR> | |
" p is for packages. | |
nnoremap <silent> [Ku]p :<C-u>Ku bundle<CR> | |
nnoremap <silent> [Ku]q :<C-u>Ku quickfix<CR> | |
nnoremap <silent> [Ku]s :<C-u>Ku source<CR> | |
nnoremap <silent> [Ku]' :<C-u>Ku source<CR> | |
" w is for ~/working. | |
"nnoremap <silent> [Ku]w :<C-u>Ku myproject<CR> | |
autocmd MyAutoCmd FileType ku | |
\ call ku#default_key_mappings(1) | |
\ | call Ku_my_keymappings() | |
\ | call ku#custom_action('bundle', 'default', 'bundle', 'args') | |
\ | call ku#custom_action('common', 'cd', s:SID_PREFIX() . 'ku_common_action_my_cd') | |
\ | call ku#custom_action('myproject', 'default', 'common', 'tab-Right') | |
\ | |
\ | call ku#custom_prefix('common', 'home', $HOME) | |
\ | call ku#custom_prefix('common', '~', $HOME) | |
\ | call ku#custom_prefix('common', '.vim', $DOTVIM) | |
\ | call ku#custom_prefix('common', '.v', $DOTVIM) | |
\ | call ku#custom_prefix('common', 'VIM', $VIMRUNTIME) | |
function! Ku_my_keymappings() | |
inoremap <buffer> <silent> <Tab> <C-n> | |
inoremap <buffer> <silent> <S-Tab> <C-p> | |
imap <buffer> <silent> <Esc><Esc> <Plug>(ku-cancel) | |
imap <buffer> <silent> jj <Plug>(ku-cancel) | |
nmap <buffer> <silent> <Esc><Esc> <Plug>(ku-cancel) | |
nmap <buffer> <silent> jj <Plug>(ku-cancel) | |
imap <buffer> <silent> <Esc><Cr> <Plug>(ku-choose-an-action) | |
nmap <buffer> <silent> <Esc><Cr> <Plug>(ku-choose-an-action) | |
endfunction | |
function! s:ku_common_action_my_cd(item) | |
if isdirectory(a:item.word) | |
execute 'CD' a:item.word | |
else " treat a:item as a file name | |
execute 'CD' fnamemodify(a:item.word, ':h') | |
endif | |
endfunction | |
" metarw.vim | |
" Define wrapper commands. | |
call metarw#define_wrapper_commands(1) | |
"}}} | |
" | |
" vim: foldmethod=marker |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment