スパム対策として書込み時にID/PWを要求されますが、ローマ字で ほげ/ホゲ で書き込めるようになります。

#norelated
*vimrc展示会場 [#ae35a334]
なんてことないvimrcでも誰かの参考になるかも。
みんなで見せっこしよう。

#contents

** vimrc_example.vimをベースに香り屋のvimrcを参考にしつつシンプルに仕上げました。 [#v1c5c299]

 set nocompatible
 
 " display
 "-----------------------------------------------------------
 " 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
 
 set shortmess+=I
 
 set list
 set listchars=tab:>-,trail:-,extends:>,precedes:<
 set display=uhex
 
 set laststatus=2
 set cmdheight=2
 set showcmd
 set title
 
 set scrolloff=2
 
 set statusline=%<%f\ %m%r%h%w%y%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%=%4v\ %l/%L
 
 " search
 "-----------------------------------------------------------
 set incsearch
 set ignorecase
 set smartcase
 
 " edit
 "-----------------------------------------------------------
 set autoindent
 set backspace=indent,eol,start
 set showmatch
 set wildmenu
 set formatoptions+=mM
 
 " tab
 "-----------------------------------------------------------
 set tabstop=8
 set shiftwidth=4
 set softtabstop=4
 set expandtab
 set smarttab
 inoremap <C-Tab> <C-V><Tab>
 
 " backup
 "-----------------------------------------------------------
 set backup
 set backupdir=~/.vim/vim_backup
 set swapfile
 set directory=~/.vim/vim_swap
 
 " key map
 " move at line
 nnoremap j gj
 nnoremap k gk
 
 " input time
 inoremap <Leader>date <C-R>=strftime('%A, %B %d, %Y')<CR>
 inoremap <Leader>time <C-R>=strftime('%H:%M')<CR>
 inoremap <Leader>rdate <C-R>=strftime('%A, %B %d, %Y %H:%M')<CR>
 inoremap <Leader>w3cdtf <C-R>=strftime('%Y-%m-%dT%H:%M:%S+09:00')<CR>
 
 " search
 vnoremap * "zy:let @/ = @z<CR>n
 
 " putline
 "-----------------------------------------------------------
 let putline_tw = 60
 
 inoremap <Leader>line <ESC>:call <SID>PutLine(putline_tw)<CR>A
 function! s:PutLine(len)
   let plen = a:len - strlen(getline('.'))
   if (plen > 0)
     execute 'normal ' plen . 'A-'
   endif
 endfunction
 
 " utf-8
 "-----------------------------------------------------------
 "let &termencoding=&encoding
 "set termencoding=utf-8
 "set encoding=utf-8
 set fileencodings=ucs-bom,iso-2022-jp-3,iso-2022-jp-2,euc-jisx0213,euc-jp,cp932
 
 if &encoding == 'utf-8'
   set ambiwidth=double
 endif
 
 " format.vim
 "-----------------------------------------------------------
 let format_allow_over_tw = 0
 
 " chalice
 "-----------------------------------------------------------
 set runtimepath+=$HOME/.vim/chalice
 nnoremap <F2> :call <SID>DoChalice()<CR>
 let chalice_preview = 0
 let chalice_columns = 120
 let chalice_exbrowser = 'openurl %URL% &'
 function! s:DoChalice()
   Chalice
 endfunction
 
 " autodate
 "-----------------------------------------------------------
 let g:autodate_format = '%Y-%m-%d'
 let g:autodate_keyword_pre = 'Last Modified:'
 let g:autodate_keyword_post = '$'
 
 " Only do this part when compiled with support for autocommands.
 if has("autocmd")
 
   " Enable file type detection.
   " Use the default filetype settings, so that mail gets 'tw' set to 72,
   " 'cindent' is on in C files, etc.
   " Also load indent files, to automatically do language-dependent indenting.
   filetype plugin indent on
 
   " Put these in an autocmd group, so that we can delete them easily.
   augroup vimrcEx
   au!
 
   " When editing a file, always jump to the last known cursor position.
   " Don't do it when the position is invalid or when inside an event handler
   " (happens when dropping a file on gvim).
   autocmd BufReadPost *
     \ if line("'\"") > 0 && line("'\"") <= line("$") |
     \   exe "normal g`\"" |
     \ endif
 
   augroup END
 
 endif " has("autocmd")

** 主に teraterm -> linux で使っています。 [#n00eae29]

 set runtimepath+=~/vimscripts/kaoriya/runtime
 
 set ic
 set bs=2
 set sw=4
 set tabstop=4
 set showmode
 set number
 set showmatch
 set ruler
 set showcmd
 set nobackup
 set nowritebackup
 set hls
 
 set cmdheight=2
 set wildchar=<Tab>
 set wildmenu
 
 set laststatus=2
 set listchars=tab:>-,extends:<,trail:-,eol:<
 set statusline=%n:\ %<%f\ %m%r%h%w[%{&fileformat}][%{has('multi_byte')&&\ &fileencoding!=''?&fileencoding:&encoding}]\ 0x%B=%b%=%l,%c\ %P
 
 set encoding=japan
 set fileencodings=ucs-bom,iso-2022-jp-3,utf-8,ucs-2le,ucs-2,cp932
 let $LANG = 'ja'
 set iminsert=0 imsearch=0
 
 nnoremap j gj
 nnoremap k gk
 
 " teraterm でもカラー表示出来るように。
 set term=builtin_linux
 set ttytype=builtin_linux
 colorscheme torte
 syntax on
 
 set dictionary+=$VIMRUNTIME/syntax/php.vim
 "set dictionary+=$VIMRUNTIME/syntax/java.vim
 
 " howm_vim
 set runtimepath+=~/vimscripts/howm_vim
 let g:howm_dir="~/memo/"
 
 set runtimepath+=~/vimscripts/pukivim
 
 set runtimepath+=~/vimscripts/bufexplorer
 set runtimepath+=~/vimscripts/winmanager
 
 "let g:winManagerWindowLayout = 'FileExplorer,TagsExplorer|BufExplorer'
 let g:winManagerWindowLayout = 'FileExplorer,BufExplorer|TagsExplorer'
 
 " minibufexpl を無効にする。
 let loaded_minibufexplorer = 1
 
 " 使う時だけ読み込む
 command! Go2ch :call Go2ch()
 function! Go2ch()
   set runtimepath+=~/vimscripts/chalice
   runtime! plugin/chalice.vim
   execute ":Chalice"
 endfunction


**この他にもあちこちで拾った関数が放りこまれてます [#n5ef70f9]
ファイル1つにまとめておいた方が持ち運びやすいのでキッチンシンク式になんでもつっこんでます。~
最新版はこちら:~
http://www.k3.dion.ne.jp/~jod/config/.vimrc~
 noremap <C-j> 3+
 noremap <C-k> 3- 
 nnoremap Y y$
 noremap # :call ToggleCommentSelection()<CR>
 nnoremap R gR
 nnoremap <Space>l :hide bn!<CR>
 nnoremap <Space>h :hide bp!<CR>
 nnoremap <Tab> <C-w>w
 nnoremap <C-h> <C-w>W
 vnoremap s y:%s/<C-R>"//g<Left><Left>
 " インサート中に誤ってエンターを押してしまったときは C-b
 inoremap <C-b> <Esc>kA
 
 " ファイル ---------------------------------------------------------
 set hidden
 set autoread
 set isfname-==
 " 2個上のディレクトリ以下から再帰的に探す
 set tags=+../../**/tags
 
 " 編集 ------------------------------------------------------------ 
 set autoindent smartindent
 set smarttab
 set tabstop=4 softtabstop=4 shiftwidth=4
 set cinoptions=t0,:0,g0,(0
 set backspace=indent,eol,start
 set formatoptions=tcqnmM
 set listchars=tab:>-
 set iskeyword+=-,!,?
 set indentkeys-=0#
 set virtualedit=block
 
 " カーソル移動 -----------------------------------------------------
 set showmatch matchtime=1
 set matchpairs+=<:>
 set whichwrap+=h,l,<,>,[,],b,s
 
 " 表示 -------------------------------------------------------------
 set nowrap
 set ruler
 set ruf=%45(%12f%=\ %m%{'['.(&fenc!=''?&fenc:&enc).']'}\ %l-%v\ %p%%\ [%02B]%)
 set statusline=%f\ %m%=%{(&fenc!=''?&fenc:&enc).':'.&ff}%{(&list?'>':'')}\ %l-%v\ %p%%\ [%02B]
 set showcmd
 set cmdheight=1
 set laststatus=2
 set nonumber
 set shortmess+=I
 set nofoldenable
 set vb t_vb=
 
 " 検索 -------------------------------------------------------------
 set ignorecase
 set smartcase
 set incsearch
 set nohlsearch
 set keywordprg=man\ -a
 
 " 補完・履歴 -------------------------------------------------------
 set wildmenu
 set history=50
 
 " ウィンドウ -------------------------------------------------------
 set splitbelow
 set splitright
 set sessionoptions+=resize
 set previewheight=5
 
 augroup MyAutocmd
   au!
   au BufEnter * lcd %:p:h 
   au BufNewFile,BufReadPost  vim   let b:commentSymbol="\""
   au BufNewFile,BufReadPost  *.c,*.h,*.cpp,*.d,*.java   let b:commentSymbol="//"
   au BufNewFile,BufReadPost  *.lua let b:commentSymbol="--"
   au BufNewFile *.h call IncludeGuard() 
   au BufNewFile *.rb call append(0, "#!/usr/bin/env ruby")
   au BufWritePost * if getline(1) =~ "^#!" | exe "silent !chmod +x %" | endif
   au BufNewFile,BufReadPost \cmakefile,*.mak setlocal list noexpandtab
   au BufNewFile,WinEnter * hi ZenkakuSpace guibg=NONE gui=underline guifg=#90e09f| match ZenkakuSpace / / 
 
   au FileType vim set sw=2 ts=2 sts=2 et 
   au FileType c,cpp call C_Setting() 
   au FileType ruby call Ruby_Setting() 
   autocmd Syntax * call MySyntax() 
 augroup END
 
 function! MySyntax()
   syn keyword Return return exit | hi Return ctermfg=red  gui=bold     guifg=red
   syn keyword Break  break | hi Break gui=none guifg=#0000ff
   syn keyword Continue continue | hi Continue gui=none guifg=#007F7F
   syn keyword Debug DEBUG debug dprintf | hi Debug ctermfg=None ctermbg=red gui=bold guifg=#ff00ff guibg=#ffffff
   syn keyword Fallthrough fallthrough | hi Fallthrough gui=underline guifg=red 
   syn keyword cppPublic public | hi cppPublic guifg=#0000ff ctermfg=darkcyan
   syn keyword cppPrivate protected private | hi cppPrivate guifg=#006600 ctermfg=darkred
   syn keyword Virtual virtual | hi Virtual guifg=brown ctermfg=3
 endfunction
 
 function! C_Setting()
   set isk-=!
   setlocal ts=4 sts=4 sw=4 noet
   set fo-=ro
   " インデントレベルを合わせて貼り付け
   nnoremap <buffer> p p=`]
   set foldmethod=syntax 
   syn region myFold start="{" end="}" transparent fold 
   set foldnestmax=1 
   iab case case<CR><C-D>break;<Up> 
   iab default: default:<CR>break;<Up>
   if filereadable("./Makefile")
     setlocal makeprg=make
   else
     setlocal makeprg=gcc\ %
   endif
 endfunction 
 
 function! Ruby_Setting()
   setlocal ts=2 sts=2 sw=2
   comp ruby
   nnoremap <buffer> <F5> :make %<CR>
   iab <buffer> ei each_with_index
 endfunction 
     
 " 現在行をコメントトグル
 " 選択中はその範囲を
 function! ToggleCommentSelection() range
   if exists('b:commentSymbol')
     let cs = b:commentSymbol
   else
     let cs = "#"
   endif 
   let cl = a:firstline
   while (cl <= a:lastline) 
     let line = getline(cl)
     if strpart(line, match(line, "[^ \t]"), strlen(cs)) == cs
       let i = 0
       while (i < strlen(cs))
         normal! ^x
         let i = i + 1
       endwhile
     else
       execute "normal! I" . cs
     endif
     normal! j
     let cl = cl + 1
   endwhile
 endfunction

----
-しょんぼり(´・ω・`) --  &new{2005-07-23 15:13:26 (土)};
-しゃきーん(`・ω・´) --  &new{2007-03-09 11:21:04 (金)};
-すばらし!! -- [[れいずん]] &new{2007-03-29 23:37:47 (木)};
-しょんぼり(´・ω・`) --  &new{2007-07-04 16:32:51 (水)};
-とうこうしずらい -- [[とうこう]] &new{2009-08-05 19:11:13 (水)};
-文句言うだけじゃなくて、投稿フォームを付けて欲しいとか、具体的な提案しないとだめじゃない? --  &new{2009-08-12 20:39:16 (水)};
-えっと投稿フォームを付けて欲しいです。BBSみたく -- [[あ]] &new{2009-08-19 18:46:50 (水)};
-vimrcもあります!! -- [[あ]] &new{2009-09-03 11:49:54 (木)};

#comment

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS