Skip to main content

dotvimrc


scriptencoding=utf-8

set mouse=a


set tags=./tags,../tags,../../tags,../../../tags,tags


function! Komment()
if getline(".") =~ '\/\*'
let hls=@/
s/^\/\*//
s/*\/$//
let @/=hls
else
let hls=@/
s/^/\/*/
s/$/*\//
let @/=hls
endif
endfunction


function! C_comment()
let hls=@/
s/^/\/\//
let @/=hls
endfunction


function! C2_comment()
let hls=@/
s/^/"/
let @/=hls
endfunction

function! C3_comment()
let hls=@/
s/^/#/
let @/=hls
endfunction

function! HTML_comment()
let hls=@/
s/^//
let @/=hls
endfunction

function! UNcomment()
let hls=@/

if getline(".") =~ '\/\/'
s/^\/\/// "for c
elseif getline(".") =~ '\"'
s/^"//
elseif getline(".") =~ '#'
s/^#//
elseif getline(".") =~ '#$'
s/^#$/$/
endif

let @/=hls
endfunction

map ,/ :call C_comment()
map ,\ :call Komment()
map ," :call C2_comment()
map ,# :call C3_comment()
map ,< :call HTML_comment()

map ,c :call UNcomment()


colorscheme torte
set nu
set hlsearch

set nocompatible
set backspace=2
set autoindent
set cindent
set smartindent
set textwidth=90
set nowrapscan
set nobackup
set novisualbell
set nojoinspaces
set ruler
set tabstop=4
set shiftwidth=4
set keywordprg=man\ -a
set showcmd
set showmatch
set ignorecase
set incsearch
set autowrite
"set linespace=2
set linespace=1
set title
set keywordprg=wdic
"set statusline=\ %<%l:%v\ [%P]%=%a\ %h%m%r\ %F\

set statusline=%<%f\ %m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%=%l,%c%V%8P
set expandtab
set wildmenu 
set laststatus=2 
set matchpairs+=<:>
syntax on


" for programming
set formatoptions=qro
set showmatch
set foldmethod=marker foldmarker={{{,}}}


" dictionary
autocmd FileType perl :set dictionary=$HOME/vim71/runtime/syntax/perl.vim
autocmd FileType cgi :set dictionary=$HOME/vim71/runtime/syntax/perl.vim
autocmd FileType c :set dictionary=$HOME/vim71/runtime/syntax/c.vim
autocmd FileType sh :set dictionary=$HOME/vim71/runtime/syntax/shell.vim
autocmd FileType html :set dictionary=$HOME/vim71/runtime/syntax/html.vim
autocmd FileType php :set dictionary=$HOME/vim71/runtime/syntax/php.vim
autocmd FileType sql :set dictionary=$HOME/vim71/runtime/syntax/sql.vim




if has("gui_running")
"set gfn=Fixedsys\ Excelsior\ 2.00\ 14
"set gfn=MiscFixed\ Semi-Condensed\ 10
"set gfw=Hangang\ Bold\ 10
"set gfw=Osaka\ 12
"set gfn=Terminal:h10:cSHIFTJIS
"set gfn=Osaka-等:h11:cSHIFTJIS
"set gfw=Osaka-等:h11:cSHIFTJIS
"set gfn=Fixedsys_Excelsior_2.00:h12:cANSI
"set gfn=Terminal:h10:cSHIFTJIS
"set gfn=Osaka-等:h11:cSHIFTJIS
"set gfw=Osaka-等:h11:cSHIFTJIS
set guifont=BDF_UM+:h9:cSHIFTJIS
set columns=120
set lines=50
" instead in /etc/vim/gvimrc
else
set guifont=BDF_M+:h7.5:cSHIFTJIS
endif



highlight SpecialKey cterm=underline ctermfg=darkgrey
"highlight ZenkakuSpace cterm=underline ctermfg=lightblue guibg=white
highlight ZenkakuSpace guibg=DarkRed
"highlight ZenkakuSpace guibg=gray40
"match ZenkakuSpace / /
"認識さ#65533;覆ぅ院璽垢�△�au BufNew,BufRead * match ZenkakuSpace / /



highlight NOTE1 cterm=bold ctermfg=Magenta guibg=Yellow guifg=Magenta
"match NOTE1 /NOTE/
au BufNew,BufRead * match NOTE1 /NOTE/

highlight TODO1 cterm=bold ctermfg=Magenta guibg=Blue guifg=Yellow
au BufNew,BufRead * match TODO1 /TODO/


autocmd BufRead *.mxml set filetype=mxml syntax=mxml

au! FileType xml,sgml,entity,xslt,svg,xhtml,xsl,xsd
\ if !exists("b:match_words") |
\ let b:match_ignorecase=0 | let b:match_words =
\ '<:>,' .
\ '<\@<=!--:-->,'.
\ '<\@<=?\k\+:?>,'.
\ '<\@<=\([^ \t>/]\+\)\%(\s\+[^>]*\%([^/]>\|$\)\|>\|$\):<\@<=/\1>,'.
\ '<\@<=\%([^ \t>/]\+\)\%(\s\+[^/>]*\|$\):/>'
\ | endif

au BufNewFile,BufRead *.html let g:snip_start_tag = "@"
au BufNewFile,BufRead *.html let g:snip_end_tag = "@"




" Jeff's cscope settings
if has("cscope")
" set csprg=/usr/bin/cscope
set csprg=~/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

" Using 'CTRL-\' then a search type makes the vim window
" "shell-out", with search results displayed on the bottom

nmap s :cs find s =expand("")
nmap g :cs find g =expand("")
nmap c :cs find c =expand("")
nmap t :cs find t =expand("")
nmap e :cs find e =expand("")
nmap f :cs find f =expand("")
nmap i :cs find i ^=expand("")$
nmap d :cs find d =expand("")

" Using 'CTRL-spacebar' then a search type makes the vim window
" split horizontally, with search result displayed in
" the new window.

nmap s :scs find s =expand("")
nmap g :scs find g =expand("")
nmap c :scs find c =expand("")
nmap t :scs find t =expand("")
nmap e :scs find e =expand("")
nmap f :scs find f =expand("")
nmap i :scs find i ^=expand("")$
nmap d :scs find d =expand("")

" Hitting CTRL-space *twice* before the search type does a vertical
" split instead of a horizontal one

nmap s :vert scs find s =expand("")
nmap g :vert scs find g =expand("")
nmap c :vert scs find c =expand("")
nmap t :vert scs find t =expand("")
nmap e :vert scs find e =expand("")
nmap i :vert scs find i ^=expand("")$
nmap d :vert scs find d =expand("")
endif



set list
"set listchars=tab:$_,trail:-,nbsp:%,extends:>,precedes:<
set listchars=tab:»·,eol:¬,trail:.,nbsp:.,extends:#,precedes:<


set encoding=utf-8
set fileencoding=utf-8


# highlighting

if has("syntax")
syntax on

function! ActivateIndicator()
"全角スペース
syntax match InvisibleJISX0208Space " " display containedin=ALL
highlight InvisibleJISX0208Space term=underline ctermbg=DarkRed guibg=DarkRed

"行末のスペースとタブ
syntax match InvisibleTrailedSpace "[ \t]\+$" display containedin=ALL
highlight InvisibleTrailedSpace term=underline ctermbg=DarkMagenta guibg=Orange

syntax match NOTE1 "NOTE" display containedin=ALL
highlight NOTE1 cterm=bold ctermfg=Magenta guibg=Magenta guifg=black

syntax match TODO1 "TODO" display containedin=ALL
highlight TODO1 cterm=bold ctermfg=Magenta guibg=Blue guifg=Yellow

syntax match suninno1 "suninno" display containedin=ALL
highlight suninno1 cterm=bold ctermfg=Magenta guibg=Yellow guifg=Green

"SpecialKeyを表示
highlight SpecialKey ctermbg=DarkGray guibg=DarkGray
endf


augroup invisible
autocmd! invisible
autocmd BufNew,BufRead * call ActivateIndicator()
augroup END
endif



if has("win32")
set shell=c:\WINDOWS\system32\cmd
set shellcmdflag=/c
endif


}}





set encoding=utf-8
set fileencoding=utf-8

" 文字コードの自動認識

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'

" iconvがeucJP-msに対応しているかをチェック

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'

" iconvがJISX0213に対応しているかをチェック

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

" fileencodingsを構築

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

" UTF-8の□や○でカーソル位置がずれないようにする

if exists("&ambiwidth")

set ambiwidth=double

endif

" 改行コードの自動認識

set fileformats=unix,dos,mac



* english menu [#id924905]
" メッセージの英語表示
if has("win32")
lang en
endif


" メニューの英語表示

source $VIMRUNTIME/delmenu.vim
set langmenu=none
source $VIMRUNTIME/menu.vim

Comments

Popular posts from this blog

맥OS 사전에 사전 파일 추가하기

1. http://code.google.com/p/mac-dictionary-kit/에서 sdconv를 다운로드 받는다. 2. e4u 등과 같은 사전 파일(stardict 형식)을 다운받는다. 3. 사전 파일의 압축을 풀면, e4u.ifo, e4u.dict.dz, e4u.idx와 같은 파일이 보인다. 4. sdconv 디렉터리 내의 convert 실행 파일로 convert e4u.ifo를 실행한다. 5. 위 과정이 완료되면 아래와 같이 사전에 e4u가 추가된 점을 확인할 수 있다. 6. 순서를 조절하여 사용하면 된다.

Sqlite database is locked

sqlite는 embedded system에서 널리 사용되는 무료 dbms?(dbms라고 말하긴 좀 그렇지만, dbms라 불러주자 ㅎ) 이다. 특히 memory db 기능이 아주 유용하다. 그 밖의 dbms에서도 이 기능이 있으나, 이 기능이 지원되는 버전은 대부분 고가이다. 따라서, 무료인 sqlite를 많이들 애용하는 것 같다. 멀티쓰레드를 sqlite DB를 구현하고 롱런테스트를 하다보면, pthread_mutex_lock으로 쓰레드 간의 교착상태를 막아줘도, sqlite lock 에러가 간헐적으로 발생할 것이다. 이에 대해 본인은 다음과 같은 에러 처리 구문을 준비하여 사용하고 있다. sqlite Error가 발생하면, sqlite3_exception함수를 호출한다. 이 함수에서 sqlite error code를 구분하여, 만약, busy 또는 locked이면 최대 2초간 sleep 상태로 만드는 sqlite3_busy_timeout, busy handler를 호출한다. 그 다음, goto 구문으로 재차 sqlite3_exec를 실행한다. 단, sqlite3_exec는 transaction의 begin과 commit 또는 rollback 구문 사이에서 실행한다. 대부분 lock 에러가 발생하더라도 1~2번 실패 후에, 처리된다는 것이 본인의 테스트 결과이다. 단, journal를 WAL로 변경하였음. 기존 journal은 멀티쓰레드 지향적이지 않다는 점을 잊지마시길.... Error Code SQLITE_LOCKED (6): Database Is Locked This error code occurs when you try to do two incompatible things with a database at the same time from the same database connection. For example, if you are in the middle of a SELECT statement and you t

SAStruts란

SAStruts 개요 Struts는 Spring Framework 다음으로 많이 사용되고 있는 FrameWork이다. Struts는 프레임워크로 강력한 기능을 제공한다. 하지만, 개발 과정에서 부수적인 설정 작업이 개발자들을 힘들게 했다. 이 문제를 해결하기 위해, 일본 개발자 커뮤니티 Seasar(일본 오키나와의 전설 동물, 우리나라의 해태와 비슷^^) 에서 개발한 프레임워크가 SAStruts(Super Agile Struts)이다. 아래 아키텍처 그림과 같이, SAStruts의 모태는 Struts이다. 다만, 상기한 복잡하고 까다로운 설정 작업을 그림2와 같이 SAStruts가 개발자 대신 내부적으로 처리해 준다. 예를 들어, Struts는 항상 struts-config.xml을 읽고 Action 클래스를 호출한다. 이 때문에, 개발자는 소스 코드를 수정한 후, 늘 struts-c onfig.xml 파일을 검토 또는 수정해야 한다. 또한, 대형 프로젝트일 경우는, 이 struts-config.xml 파일이 경합을 자주 일으킨다. 이는 실로 개발자의 스트레스 치수를 높이는 원인이다. 반면, SAStruts는 이 번거로운 작업을 알아서 처리해 준다. 아리가또~~~ 입니다. 그림1 Struts 아키텍처 그림2 SAStruts 아키텍처 그럼, 이 번거로운 작업을 SAStruts는 어떻게 처리하는 것인지 궁금할 것이다. 그것은 Java의 annotation기술을 이용한 점이다. 예를 들어, @Execute, @ActionForm, @Resource 등 Seasar 커뮤니티에서 제공하는 Dolteng 플러그인을 사용하면, SAStruts 개발이 더욱 효율적이다. SAStruts 프로젝트는 다음과 같은 패키지 구조로 형성된다. [root package].action Action 클래스 [root package].condition 데이터베이스에 엑세스하는 조건 설정 [root packa