2011年5月のvimrc

Linuxのエディターはもちろん、Macのエディターも会社のWindowsのエディターもVimで、inputrcに set editing-mode vi と書かないと気が済まず、IDEはエディター画面にviモードがあることが必須条件で、いつのまにか会社で共用するマシンのvimrcメンテナーになっていたボクの、長年改変し続けているvimrcをここで公開する。一つ一つの項目の説明はコメント以上にはないので、:helpするかインターネット検索するかコメントで問い合わせてほしい。以下は Vim 7.0 で動作確認したものだ。最新のファイルは GitHub: rewse: dotfiles にある。

" {{{ Variables

if has('unix')
  let uname = system('uname')
else
  let uname = 'UNKNOWN'
endif

" }}}
" {{{ for Japanese

if uname =~ 'Linux'
  set encoding=utf-8
elseif has(- 'gui_macvim')
  set encoding=japan
endif

if has('iconv')
  set fileencodings=us-ascii,utf-8

  if &encoding ==? 'euc-jp'
    set fileencodings+=cp932,euc-jp
  else
    set fileencodings+=euc-jp,cp932
  endif
endif

set fileencoding=utf-8

set fileformats=unix,dos,mac

set fileformat=unix

if has(- 'gui_macvim')
  set langmenu=japanese
endif

" }}}
" {{{ Color for Console

if has('win32')
  set term=win32
elseif uname =~ 'Linux'
  set term=builtin_linux
else
  set term=xterm-color
endif

" }}}
" {{{ about Edit
"

" Backspace over anything
set backspace=indent,eol,start

" Width of tab
set tabstop=2
set shiftwidth=2
set softtabstop=2

" Expand tab to space
set expandtab

" Show matching of bracket
set showmatch

" Folding marker is {{{ }}}
set foldmethod=marker
set nofoldenable

" IM is off
set iminsert=0
set imsearch=0

" Ignore octal and hex
set nrformats=""

" }}}
" {{{ about Find

" Ignore case
set ignorecase

" Case-sensitive including small-caps with large-caps
set smartcase

" Return 1st line when go to last line
set wrapscan

" Incrimental search
set incsearch

" }}}
" {{{ about Display

" Show tab and return
set list

" How show for tab and return
set listchars=tab:>-,trail:_

" Show line number
set number

" Support Japanese for auto line wrapping
set formatoptions+=mM

" Show rular
set ruler

" Show title
set title

" Hide toolbar
set guioptions-=T

" Hide startup message
set shortmess+=I

" Set status line
set statusline=%<%f\ %m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%=%l,%c%V%8P

" Show command at status line
set showcmd

" Always show status line
set laststatus=2

" Beep by visual
set visualbell

" Use syntax highlight
syntax on

" Use default color scheme
colorscheme default

" }}}
" {{{ About file handling

" Do not backup

set nobackup
set backupext=.bak

" }}}
" {{{ About Buffer

set hidden

" }}}
" {{{ Key Mapping

" Set <leader>
let mapleader = " "

" Handling a wrapped line as same as 2 lines
nnoremap j gj
nnoremap k gk

" Remap command and search history
nnoremap q: qq:
nnoremap q/ qq/
nnoremap q? qq?

noremap <C-]> <Esc>
inoremap <C-]> <Esc>

" }}}
" {{{ Variables

unlet uname

" }}}
" {{{ Color

gui
colorscheme default
hi StatusLine term=reverse cterm=reverse,bold ctermbg=red ctermfg=white gui=reverse,bold guibg=white guifg=#DF0000

" }}}
" {{{ Window

" Window Size
set columns=80
set lines=40

" }}}
" {{{ Font

if has('gui_macvim')
  set guifont:M+2VM+IPAG\ circle\ Regular:h14
elseif has('win32')
  set guifont:MeiryoKe_Gothic:h10
endif

" }}}
" {{{ Key Mapping

if has('gui_macvim')
  noremap <D-x> "+d
  noremap <D-c> "+y
  noremap <D-v> "+P
  noremap <D-V> "+p
  noremap <D-S-v> "+p
  inoremap <D-v> <C-o>"+P
  inoremap <D-V> <C-o>"+p
  inoremap <D-S-v> <C-o>"+p
  cnoremap <D-v> <C-r>+
  noremap <D-a> ggVG
  nnoremap <C-t> :tabedit<Return>
  nnoremap <C-w> :tabclose<Return>
  nnoremap <C-}> :tabnext<Return>
  nnoremap <C-{> :tabprevious<Return>
elseif has('win32')
  set winaltkeys=no
  noremap <A-x> "+d
  noremap <A-c> "+y
  noremap <A-v> "+P
  noremap <A-S-v> "+p
  inoremap <A-v> <C-o>"+P
  inoremap <A-S-v> <C-o>"+p
  cnoremap <A-v> <C-r>+
  noremap <A-a> ggVG
  nnoremap <C-t> :tabedit<Return>
  nnoremap <C-w> :tabclose<Return>
  nnoremap <C-Tab> :tabnext<Return>
  nnoremap <C-S-Tab> :tabprevious<Return>
endif

" }}}

2011年5月のvimrc への2件のコメント

  1. [...] /etc/profile.d, /etc/inputrc, /etc/screenrc, /etc/vimrc にいつもの設定を追加する。vimrcについては 複眼中心: 2011年5月のvimrc を参照してほしい。 [...]

  2. [...] /etc/profile.d, /etc/inputrc, /etc/screenrc, /etc/vimrc にいつもの設定を追加する。vimrcについては 複眼中心: 2011年5月のvimrc を参照してほしい。 [...]

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

トラックバックをどうぞ

言及リンクがないと(あなたのページにこのページへのリンクがないと)トラックバックできません。