A Text Editor -- Vim のメモ
蒋 いつ峰 2008/05/28   |  開発色々
vimrc ファイル 2008/05/28  |  PK:vimrc

【2008/4/27 作者追記】これを書いてから半年位経ちました、この間、Vimの理解を深めたと伴い、私のvimrcファイルも大分変わりました。
これらについて、及び現在使用中のvimrcは Vimでシステム開発 で紹介します。

【2008/5/28 作者追記】
現在使っている私のvimrcの最新版はこちら、14.私のvimrc にあります。以下の内容を無視してください。
 

vimrc は Vim の設定ファイルです。Linux の場合は $HOME/.vimrc です、Windows は $VIM/_vimrc です($VIMは Vim のインストール場所)。

凄く長い vimrc を設定している Vim ファンもいるが、私のほうは初心者なので、ちょっとだけしかカスタマイズしていない。以下の通りです。

if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
   set fileencodings=utf-8,latin1
endif

set nocompatible    " Use Vim defaults (much better!)
set bs=indent,eol,start        " allow backspacing over everything in insert mode
"set ai            " always set autoindenting on
"set backup        " keep a backup file
set viminfo=’20,\"50    " read/write a .viminfo file, don’t store more than 50 lines of registers
set history=50        " keep 50 lines of command line history
set ruler        " show the cursor position all the time

" Only do this part when compiled with support for autocommands
if has("autocmd")
  " In text files, always limit the width of text to 78 characters
  autocmd BufRead *.txt set tw=78
  " When editing a file, always jump to the last cursor position
  autocmd BufReadPost *
  \ if line("’\"") > 0 && line ("’\"") <= line("$") |
  \   exe "normal! g’\"" |
  \ endif
endif

if has("cscope") && filereadable("/usr/bin/cscope")
   set csprg=/usr/bin/cscope
   set csto=0
   set cst
   set nocsverb
   " add any database in current directory
   if filereadable("cscope.out")
      cs add cscope.out
   " else add database pointed to by environment
   elseif $CSCOPE_DB != ""
      cs add $CSCOPE_DB
   endif
   set csverb
endif

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.

if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif

if &term=="xterm"
     set t_Co=8
     set t_Sb=[4%dm
     set t_Sf=[3%dm
endif

"tabspace
set ts=2
set sw=2
set expandtab

"大文字、小文字
set ignorecase

"フォント
set guifont=IPAゴシック\ 11

set iminsert=0  "入力モードでのIMEのデフォルト状態
set imsearch=0  "検索モードでのIMEのデフォルト状態
set ignorecase  "検索時大文字、小文字を区別しない
set statusline=%<%f\ %m%r%h%w%{’[’.(&fenc!=’’?&fenc:&enc).’][’.&ff.’]’}%=%l,%c%V%8P " ステータスラインに文字コードと改行文字を表示する
set nowrapscan    " 検索でファイル終端に来たら先頭に戻る
set laststatus=2  " ステータスラインを常に表示
set tenc=euc-jp " ターミナルの文字コード解釈(utf-8, euc-jp)
set fencs=utf-8,euc-jp,cp932,big5,cp936,ucs-2le,ucs-2,iso-2022-jp
set backupdir=/home/uprush/tmp

" 挿入モード中に日付と時間を挿入
inoremap <C-D> <C-R>=strftime("%Y-%m-%d")<CR>
inoremap <C-T> <C-R>=strftime("%H:%M:%S")<CR>

"印刷用
if has(’printer’)
  if has(’win32’)
      set printfont=MS_ゴシック:h9:cSHIFTJIS
  elseif has("unix")
     set printencoding=euc-jp
         if exists(’&printmbcharset’)
            set printmbcharset=JIS_X_1983
            set printmbfont=r:Ryumin-Light,b:Ryumin-Light,a:yes,c:yes
         endif
  endif
endif
      
"sqlutil
let g:sqlutil_align_where = 1
let g:sqlutil_align_comma = 1

"taglist
let g:ctags_path="/usr/share/vim/vim70/plugin"
set tags=tags

"matchit
let b:match_words="\<function\>:\<end function\>"
let b:match_ignorecase = 1

"enable mswin
source $VIMRUNTIME/mswin.vim
behave mswin

" if windows, detect mac format
if $OSTYPE==’cygwin’ || $TERM==’cygwin’ || exists("$HOMEDRIVE")
  set fileformats+=mac
endif

"autocmd
autocmd FileType jsp,asp,php,xml,perl syntax sync minlines=500 maxlines=1000
autocmd FileType python setlocal ts=4 sw=4 sta et sts ai

" colorscheme
if has("gui_running")
  colorscheme desert
else
  if $TERM==’rxvt’
    silent! colorscheme blue
  elseif $TERM==’cygwin’
    silent! colorscheme autumn
  else
    silent! colorscheme torte
  endif
endif

" Buffer  変更時、該当ファイルのフォルダへ移動

function! CHANGE_CURR_DIR()
let _dir = expand("%:p:h")
exec "cd " . _dir
unlet _dir
endfunction

autocmd BufEnter * call CHANGE_CURR_DIR()

" Escを押すと、Highlightを消す
nnoremap <silent> <ESC> <ESC>:noh<CR>

 


閲覧  |  コメント  |  目次

 
ヘルプ  |  ご利用規約  |  相互リンク  |  問合せ
リンクはご自由に、問合せはお気軽に
©2007 Uprush