Linuxで使用可能な .vimrc. 人から貰った。 文字コードの自動判定辺りは、 - "vim - 文字コードの自動認識" -- http://www.ksknet.net/vi/vim_1.html - "VIM関係" -- http://fedorakenken.at-ninja.jp/node42.html - "ずんWiki - vim" -- http://www.kawaz.jp/pukiwiki/?vim 周りから引き継がれた模様。 #more|| ---- #pre||> 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' 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' 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 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 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 set nocompatible set history=999 " keep 50 lines of command line history set ruler " show the cursor position all the time set showcmd " display incomplete commands set incsearch " do incremental searching " 単純なテキストファイルなどのTAB幅は4としておく。 " 各言語用のTAB幅は、後述のautocmdでsetlocalして指定する。 set tabstop=4 set shiftwidth=4 " 同様に単純なテキストファイルなどデフォルトではTAB文字としてそのままにしておく。 "set expandtab " これも? set backspace=2 set shortmess+=I set visualbell " 特殊記号の表示 set listchars=tab:>-,extends:<,trail:- "set listchars=eol:$,tab:>-- "set listchars=eol:$,tab:>- "set listchars=tab:\ \ "これを使うとTABが見えなくなる。アンチパターンとして。 set grepprg=search\ $* set number set showmatch set showmode " autocmdが確実に入っているのであれば下記2行のような設定も可能。 "autocmd FileType php :set dictionary+=~/.vim/php.dict "autocmd FileType yaml :set expandtab set complete+=k set title map Q gq if has("autocmd") autocmd FileType text setlocal textwidth=78 autocmd FileType c setlocal expandtab tabstop=4 shiftwidth=4 autocmd FileType perl setlocal expandtab tabstop=4 shiftwidth=4 autocmd FileType php setlocal expandtab tabstop=4 shiftwidth=4 autocmd FileType ruby setlocal expandtab tabstop=4 shiftwidth=4 autocmd FileType python setlocal expandtab tabstop=2 shiftwidth=2 autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif endif " has("autocmd") set ignorecase set smartcase set wrapscan syntax on set list set hlsearch set laststatus=2 set statusline=%<%f\ %m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%=%l,%c%V%8P map :bp map :bn map :bw nnoremap j gj nnoremap k gk map + map - "set tags+=~/tags/tags "set tags+=~/.ctags/symfony hi Comment ctermfg=lightred hi Function ctermfg=cyan set autoindent " always set autoindenting on set autochdir "set nocp set nobackup set backupcopy=yes set fdm=marker ||<